if (CryptoProperties.type().orElse(CryptoProperties.type_values.NONE) != CryptoProperties.type_values.FILE) {
            return;
        }

package com.android.settings.development;

import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.storage.IStorageManager;
import android.text.TextUtils;
import android.sysprop.CryptoProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;

public class FileEncryptionPreferenceController extends DeveloperOptionsPreferenceController implements PreferenceControllerMixin {

    private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";

    private static final String KEY_STORAGE_MANAGER = "mount";

    private final IStorageManager mStorageManager;

    public FileEncryptionPreferenceController(Context context) {
        super(context);
        mStorageManager = getStorageManager();
    }

    @Override
    public boolean isAvailable() {
        if (mStorageManager == null) {
            return false;
        }
        try {
            return mStorageManager.isConvertibleToFBE();
        } catch (RemoteException e) {
            return false;
        }
    }

    @Override
    public String getPreferenceKey() {
        return KEY_CONVERT_FBE;
    }

    @Override
    public void updateState(Preference preference) {

        mPreference.setEnabled(false);
        mPreference.setSummary(mContext.getResources().getString(R.string.convert_to_file_encryption_done));
    }

    private IStorageManager getStorageManager() {
        try {
            return IStorageManager.Stub.asInterface(ServiceManager.getService(KEY_STORAGE_MANAGER));
        } catch (VerifyError e) {
            // Used for tests since Robolectric cannot initialize this class.
            return null;
        }
    }
}


try {
            return mStorageManager.isConvertibleToFBE();
        } catch (RemoteException e) {
            return false;
        }

package com.android.settings.development;

import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.storage.IStorageManager;
import android.text.TextUtils;
import android.sysprop.CryptoProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;

public class FileEncryptionPreferenceController extends DeveloperOptionsPreferenceController implements PreferenceControllerMixin {

    private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";

    private static final String KEY_STORAGE_MANAGER = "mount";

    private final IStorageManager mStorageManager;

    public FileEncryptionPreferenceController(Context context) {
        super(context);
        mStorageManager = getStorageManager();
    }

    @Override
    public boolean isAvailable() {
        if (mStorageManager == null) {
            return false;
        }

    }

    @Override
    public String getPreferenceKey() {
        return KEY_CONVERT_FBE;
    }

    @Override
    public void updateState(Preference preference) {
        if (CryptoProperties.type().orElse(CryptoProperties.type_values.NONE) != CryptoProperties.type_values.FILE) {
            return;
        }
        mPreference.setEnabled(false);
        mPreference.setSummary(mContext.getResources().getString(R.string.convert_to_file_encryption_done));
    }

    private IStorageManager getStorageManager() {
        try {
            return IStorageManager.Stub.asInterface(ServiceManager.getService(KEY_STORAGE_MANAGER));
        } catch (VerifyError e) {
            // Used for tests since Robolectric cannot initialize this class.
            return null;
        }
    }
}


@Before
    public void setUp() throws Exception

package com.ardovic.weatherappprototype.network;

import android.os.Handler;
import android.os.HandlerThread;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.Callable;
import static org.junit.Assert.*;
import static org.mockito.Mockito.calls;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/**
 * Created by user on 01.04.2018.
 */
public class FetchThreadDataTest {

    FetchThreadData<String> fetchThreadData;

    public FetchThreadDataTest() {
    }

{
        Handler handler = mock(Handler.class);
        fetchThreadData = new FetchThreadData<>(handler);
        fetchThreadData.start();
        fetchThreadData.getLooper();
    }

    @Test
    public void queueResponce() throws Exception {
        fetchThreadData.queueResponce("f", "a");
        fetchThreadData.queueResponce("c", "a");
        fetchThreadData.queueResponce("a", "a");
        fetchThreadData.queueResponce("d", "a");
    }
}


{
        fetchThreadData.queueResponce("f", "a");
        fetchThreadData.queueResponce("c", "a");
        fetchThreadData.queueResponce("a", "a");
        fetchThreadData.queueResponce("d", "a");
    }

package com.ardovic.weatherappprototype.network;

import android.os.Handler;
import android.os.HandlerThread;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.Callable;
import static org.junit.Assert.*;
import static org.mockito.Mockito.calls;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/**
 * Created by user on 01.04.2018.
 */
public class FetchThreadDataTest {

    FetchThreadData<String> fetchThreadData;

    public FetchThreadDataTest() {
    }

    @Before
    public void setUp() throws Exception {
        Handler handler = mock(Handler.class);
        fetchThreadData = new FetchThreadData<>(handler);
        fetchThreadData.start();
        fetchThreadData.getLooper();
    }

    @Test
    public void queueResponce() throws Exception


package com.ardovic.weatherappprototype.network;

import android.os.Handler;
import android.os.HandlerThread;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.Callable;
import static org.junit.Assert.*;
import static org.mockito.Mockito.calls;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/**
 * Created by user on 01.04.2018.
 */
public class FetchThreadDataTest {

    FetchThreadData<String> fetchThreadData;

    public FetchThreadDataTest() {
    }

    @Before
    public void setUp() throws Exception {
        Handler handler = mock(Handler.c

        fetchThreadData = new FetchThreadData<>(handler);
        fetchThreadData.start();
        fetchThreadData.getLooper();
    }

    @Test
    public void queueResponce() throws Exception {
        fetchThreadData.queueResponce("f", "a");
        fetchThreadData.queueResponce("c", "a");
        fetchThreadData.queueResponce("a", "a");
        fetchThreadData.queueResponce("d", "a");
    }
}


public CreateVolumeOptions description(String description)

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */

{
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


{
        return availabilityZone;
    }

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone()

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


        if (this == object) {
            return true;
        }

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {

        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }

        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name

        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);
        if (description != null)
            image.put("display_description", description);
        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


if (description != null)
            image.put("display_description", description);

package org.jclouds.openstack.cinder.v1.options;

import static com.google.common.base.Objects.equal;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class CreateVolumeOptions implements MapBinder {

    public static final CreateVolumeOptions NONE = new CreateVolumeOptions();

    @Inject
    private BindToJsonPayload jsonBinder;

    protected String name;

    protected String description;

    protected String volumeType;

    protected String availabilityZone;

    protected String snapshotId;

    protected Map<String, String> metadata = ImmutableMap.of();

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
        Map<String, Object> image = Maps.newHashMap();
        image.putAll(postParams);
        if (name != null)
            image.put("display_name", name);

        if (volumeType != null)
            image.put("volume_type", volumeType);
        if (availabilityZone != null)
            image.put("availability_zone", availabilityZone);
        if (snapshotId != null)
            image.put("snapshot_id", snapshotId);
        if (!metadata.isEmpty())
            image.put("metadata", metadata);
        return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
    }

    @Override
    public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
        throw new IllegalStateException("CreateVolume is a POST operation");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof CreateVolumeOptions))
            return false;
        final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
        return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId) && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
    }

    protected ToStringHelper string() {
        return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
    }

    @Override
    public String toString() {
        return string().toString();
    }

    /**
     * Custom cloud server metadata can also be supplied at launch time. This
     * metadata is stored in the API system where it is retrievable by querying
     * the API for server status. The maximum size of the metadata key and value
     * is each 255 bytes and the maximum number of key-value pairs that can be
     * supplied per volume is 5.
     */
    public CreateVolumeOptions metadata(Map<String, String> metadata) {
        checkNotNull(metadata, "metadata");
        checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values.  You specified: " + metadata.size());
        for (Entry<String, String> entry : metadata.entrySet()) {
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata key is 255 bytes.  Key specified %s is %d bytes", entry.getKey(), entry.getKey().getBytes().length));
            checkArgument(entry.getKey().getBytes().length < 255, String.format("maximum length of metadata value is 255 bytes.  Value specified for %s (%s) is %d bytes", entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
        }
        this.metadata = ImmutableMap.copyOf(metadata);
        return this;
    }

    /**
     * @param name The name of the Volume
     */
    public CreateVolumeOptions name(String name) {
        this.name = name;
        return this;
    }

    /**
     * @param description A description of the Volume
     */
    public CreateVolumeOptions description(String description) {
        this.description = description;
        return this;
    }

    /**
     * @see VolumeTypeApi#list()
     *
     * @param volumeType The type of Volume to create
     */
    public CreateVolumeOptions volumeType(String volumeType) {
        this.volumeType = volumeType;
        return this;
    }

    /**
     * @param availabilityZone The optional availability zone in which to create a Volume
     */
    public CreateVolumeOptions availabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
        return this;
    }

    /**
     * @param snapshotId The optional snapshot from which to create a Volume
     */
    public CreateVolumeOptions snapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
        return this;
    }

    public String getVolumeType() {
        return volumeType;
    }

    public String getAvailabilityZone() {
        return availabilityZone;
    }

    public String getSnapshotId() {
        return snapshotId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public static class Builder {

        /**
         * @see CreateVolumeOptions#getName()
         */
        public static CreateVolumeOptions name(String name) {
            return new CreateVolumeOptions().name(name);
        }

        /**
         * @see CreateVolumeOptions#getDescription()
         */
        public static CreateVolumeOptions description(String description) {
            return new CreateVolumeOptions().description(description);
        }

        /**
         * @see CreateVolumeOptions#getVolumeType()
         */
        public static CreateVolumeOptions volumeType(String volumeType) {
            return new CreateVolumeOptions().volumeType(volumeType);
        }

        /**
         * @see CreateVolumeOptions#getAvailabilityZone()
         */
        public static CreateVolumeOptions availabilityZone(String availabilityZone) {
            return new CreateVolumeOptions().availabilityZone(availabilityZone);
        }

        /**
         * @see CreateVolumeOptions#getSnapshotId()
         */
        public static CreateVolumeOptions snapshotId(String snapshotId) {
            return new CreateVolumeOptions().snapshotId(snapshotId);
        }

        /**
         * @see CreateVolumeOptions#getMetadata()
         */
        public static CreateVolumeOptions metadata(Map<String, String> metadata) {
            return new CreateVolumeOptions().metadata(metadata);
        }
    }
}


@Override
    protected void _setLongLE(int index, long value)

package io.netty.buffer;

import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.ObjectCreator;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;

final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {

    private static final ObjectPool<PooledDirectByteBuf> RECYCLER = ObjectPool.newPool(new ObjectCreator<PooledDirectByteBuf>() {

        @Override
        public PooledDirectByteBuf newObject(Handle<PooledDirectByteBuf> handle) {
            return new PooledDirectByteBuf(handle, 0);
        }
    });

    static PooledDirectByteBuf newInstance(int maxCapacity) {
        PooledDirectByteBuf buf = RECYCLER.get();
        buf.reuse(maxCapacity);
        return buf;
    }

    private PooledDirectByteBuf(Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity) {
        super(recyclerHandle, maxCapacity);
    }

    @Override
    protected ByteBuffer newInternalNioBuffer(ByteBuffer memory) {
        return memory.duplicate();
    }

    @Override
    public boolean isDirect() {
        return true;
    }

    @Override
    protected byte _getByte(int index) {
        return memory.get(idx(index));
    }

    @Override
    protected short _getShort(int index) {
        return memory.getShort(idx(index));
    }

    @Override
    protected short _getShortLE(int index) {
        return ByteBufUtil.swapShort(_getShort(index));
    }

    @Override
    protected int _getUnsignedMedium(int index) {
        index = idx(index);
        return (memory.get(index) & 0xff) << 16 | (memory.get(index + 1) & 0xff) << 8 | memory.get(index + 2) & 0xff;
    }

    @Override
    protected int _getUnsignedMediumLE(int index) {
        index = idx(index);
        return memory.get(index) & 0xff | (memory.get(index + 1) & 0xff) << 8 | (memory.get(index + 2) & 0xff) << 16;
    }

    @Override
    protected int _getInt(int index) {
        return memory.getInt(idx(index));
    }

    @Override
    protected int _getIntLE(int index) {
        return ByteBufUtil.swapInt(_getInt(index));
    }

    @Override
    protected long _getLong(int index) {
        return memory.getLong(idx(index));
    }

    @Override
    protected long _getLongLE(int index) {
        return ByteBufUtil.swapLong(_getLong(index));
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.capacity());
        if (dst.hasArray()) {
            getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
        } else if (dst.nioBufferCount() > 0) {
            for (ByteBuffer bb : dst.nioBuffers(dstIndex, length)) {
                int bbLen = bb.remaining();
                getBytes(index, bb);
                index += bbLen;
            }
        } else {
            dst.setBytes(dstIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.length);
        _internalNioBuffer(index, length, true).get(dst, dstIndex, length);
        return this;
    }

    @Override
    public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
        checkDstIndex(length, dstIndex, dst.length);
        _internalNioBuffer(readerIndex, length, false).get(dst, dstIndex, length);
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuffer dst) {
        dst.put(duplicateInternalNioBuffer(index, dst.remaining()));
        return this;
    }

    @Override
    public ByteBuf readBytes(ByteBuffer dst) {
        int length = dst.remaining();
        checkReadableBytes(length);
        dst.put(_internalNioBuffer(readerIndex, length, false));
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
        getBytes(index, out, length, false);
        return this;
    }

    private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException {
        checkIndex(index, length);
        if (length == 0) {
            return;
        }
        ByteBufUtil.readBytes(alloc(), internal ? internalNioBuffer() : memory.duplicate(), idx(index), length, out);
    }

    @Override
    public ByteBuf readBytes(OutputStream out, int length) throws IOException {
        checkReadableBytes(length);
        getBytes(readerIndex, out, length, true);
        readerIndex += length;
        return this;
    }

    @Override
    protected void _setByte(int index, int value) {
        memory.put(idx(index), (byte) value);
    }

    @Override
    protected void _setShort(int index, int value) {
        memory.putShort(idx(index), (short) value);
    }

    @Override
    protected void _setShortLE(int index, int value) {
        _setShort(index, ByteBufUtil.swapShort((short) value));
    }

    @Override
    protected void _setMedium(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) (value >>> 16));
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) value);
    }

    @Override
    protected void _setMediumLE(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) value);
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) (value >>> 16));
    }

    @Override
    protected void _setInt(int index, int value) {
        memory.putInt(idx(index), value);
    }

    @Override
    protected void _setIntLE(int index, int value) {
        _setInt(index, ByteBufUtil.swapInt(value));
    }

    @Override
    protected void _setLong(int index, long value) {
        memory.putLong(idx(index), value);
    }

{
        _setLong(index, ByteBufUtil.swapLong(value));
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.capacity());
        if (src.hasArray()) {
            setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
        } else if (src.nioBufferCount() > 0) {
            for (ByteBuffer bb : src.nioBuffers(srcIndex, length)) {
                int bbLen = bb.remaining();
                setBytes(index, bb);
                index += bbLen;
            }
        } else {
            src.getBytes(srcIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.length);
        _internalNioBuffer(index, length, false).put(src, srcIndex, length);
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuffer src) {
        int length = src.remaining();
        checkIndex(index, length);
        ByteBuffer tmpBuf = internalNioBuffer();
        if (src == tmpBuf) {
            src = src.duplicate();
        }
        index = idx(index);
        tmpBuf.limit(index + length).position(index);
        tmpBuf.put(src);
        return this;
    }

    @Override
    public int setBytes(int index, InputStream in, int length) throws IOException {
        checkIndex(index, length);
        byte[] tmp = ByteBufUtil.threadLocalTempArray(length);
        int readBytes = in.read(tmp, 0, length);
        if (readBytes <= 0) {
            return readBytes;
        }
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.position(idx(index));
        tmpBuf.put(tmp, 0, readBytes);
        return readBytes;
    }

    @Override
    public ByteBuf copy(int index, int length) {
        checkIndex(index, length);
        ByteBuf copy = alloc().directBuffer(length, maxCapacity());
        return copy.writeBytes(this, index, length);
    }

    @Override
    public boolean hasArray() {
        return false;
    }

    @Override
    public byte[] array() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public int arrayOffset() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public boolean hasMemoryAddress() {
        return false;
    }

    @Override
    public long memoryAddress() {
        throw new UnsupportedOperationException();
    }
}


{
        return memory.getShort(idx(index));
    }

package io.netty.buffer;

import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.ObjectCreator;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;

final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {

    private static final ObjectPool<PooledDirectByteBuf> RECYCLER = ObjectPool.newPool(new ObjectCreator<PooledDirectByteBuf>() {

        @Override
        public PooledDirectByteBuf newObject(Handle<PooledDirectByteBuf> handle) {
            return new PooledDirectByteBuf(handle, 0);
        }
    });

    static PooledDirectByteBuf newInstance(int maxCapacity) {
        PooledDirectByteBuf buf = RECYCLER.get();
        buf.reuse(maxCapacity);
        return buf;
    }

    private PooledDirectByteBuf(Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity) {
        super(recyclerHandle, maxCapacity);
    }

    @Override
    protected ByteBuffer newInternalNioBuffer(ByteBuffer memory) {
        return memory.duplicate();
    }

    @Override
    public boolean isDirect() {
        return true;
    }

    @Override
    protected byte _getByte(int index) {
        return memory.get(idx(index));
    }

    @Override
    protected short _getShort(int index)

    @Override
    protected short _getShortLE(int index) {
        return ByteBufUtil.swapShort(_getShort(index));
    }

    @Override
    protected int _getUnsignedMedium(int index) {
        index = idx(index);
        return (memory.get(index) & 0xff) << 16 | (memory.get(index + 1) & 0xff) << 8 | memory.get(index + 2) & 0xff;
    }

    @Override
    protected int _getUnsignedMediumLE(int index) {
        index = idx(index);
        return memory.get(index) & 0xff | (memory.get(index + 1) & 0xff) << 8 | (memory.get(index + 2) & 0xff) << 16;
    }

    @Override
    protected int _getInt(int index) {
        return memory.getInt(idx(index));
    }

    @Override
    protected int _getIntLE(int index) {
        return ByteBufUtil.swapInt(_getInt(index));
    }

    @Override
    protected long _getLong(int index) {
        return memory.getLong(idx(index));
    }

    @Override
    protected long _getLongLE(int index) {
        return ByteBufUtil.swapLong(_getLong(index));
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.capacity());
        if (dst.hasArray()) {
            getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
        } else if (dst.nioBufferCount() > 0) {
            for (ByteBuffer bb : dst.nioBuffers(dstIndex, length)) {
                int bbLen = bb.remaining();
                getBytes(index, bb);
                index += bbLen;
            }
        } else {
            dst.setBytes(dstIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.length);
        _internalNioBuffer(index, length, true).get(dst, dstIndex, length);
        return this;
    }

    @Override
    public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
        checkDstIndex(length, dstIndex, dst.length);
        _internalNioBuffer(readerIndex, length, false).get(dst, dstIndex, length);
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuffer dst) {
        dst.put(duplicateInternalNioBuffer(index, dst.remaining()));
        return this;
    }

    @Override
    public ByteBuf readBytes(ByteBuffer dst) {
        int length = dst.remaining();
        checkReadableBytes(length);
        dst.put(_internalNioBuffer(readerIndex, length, false));
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
        getBytes(index, out, length, false);
        return this;
    }

    private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException {
        checkIndex(index, length);
        if (length == 0) {
            return;
        }
        ByteBufUtil.readBytes(alloc(), internal ? internalNioBuffer() : memory.duplicate(), idx(index), length, out);
    }

    @Override
    public ByteBuf readBytes(OutputStream out, int length) throws IOException {
        checkReadableBytes(length);
        getBytes(readerIndex, out, length, true);
        readerIndex += length;
        return this;
    }

    @Override
    protected void _setByte(int index, int value) {
        memory.put(idx(index), (byte) value);
    }

    @Override
    protected void _setShort(int index, int value) {
        memory.putShort(idx(index), (short) value);
    }

    @Override
    protected void _setShortLE(int index, int value) {
        _setShort(index, ByteBufUtil.swapShort((short) value));
    }

    @Override
    protected void _setMedium(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) (value >>> 16));
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) value);
    }

    @Override
    protected void _setMediumLE(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) value);
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) (value >>> 16));
    }

    @Override
    protected void _setInt(int index, int value) {
        memory.putInt(idx(index), value);
    }

    @Override
    protected void _setIntLE(int index, int value) {
        _setInt(index, ByteBufUtil.swapInt(value));
    }

    @Override
    protected void _setLong(int index, long value) {
        memory.putLong(idx(index), value);
    }

    @Override
    protected void _setLongLE(int index, long value) {
        _setLong(index, ByteBufUtil.swapLong(value));
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.capacity());
        if (src.hasArray()) {
            setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
        } else if (src.nioBufferCount() > 0) {
            for (ByteBuffer bb : src.nioBuffers(srcIndex, length)) {
                int bbLen = bb.remaining();
                setBytes(index, bb);
                index += bbLen;
            }
        } else {
            src.getBytes(srcIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.length);
        _internalNioBuffer(index, length, false).put(src, srcIndex, length);
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuffer src) {
        int length = src.remaining();
        checkIndex(index, length);
        ByteBuffer tmpBuf = internalNioBuffer();
        if (src == tmpBuf) {
            src = src.duplicate();
        }
        index = idx(index);
        tmpBuf.limit(index + length).position(index);
        tmpBuf.put(src);
        return this;
    }

    @Override
    public int setBytes(int index, InputStream in, int length) throws IOException {
        checkIndex(index, length);
        byte[] tmp = ByteBufUtil.threadLocalTempArray(length);
        int readBytes = in.read(tmp, 0, length);
        if (readBytes <= 0) {
            return readBytes;
        }
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.position(idx(index));
        tmpBuf.put(tmp, 0, readBytes);
        return readBytes;
    }

    @Override
    public ByteBuf copy(int index, int length) {
        checkIndex(index, length);
        ByteBuf copy = alloc().directBuffer(length, maxCapacity());
        return copy.writeBytes(this, index, length);
    }

    @Override
    public boolean hasArray() {
        return false;
    }

    @Override
    public byte[] array() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public int arrayOffset() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public boolean hasMemoryAddress() {
        return false;
    }

    @Override
    public long memoryAddress() {
        throw new UnsupportedOperationException();
    }
}


        checkIndex(index, length);
        byte[] tmp = ByteBufUtil.threadLocalTempArray(length);
        int readBytes = in.read(tmp, 0, length);

package io.netty.buffer;

import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.ObjectCreator;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;

final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {

    private static final ObjectPool<PooledDirectByteBuf> RECYCLER = ObjectPool.newPool(new ObjectCreator<PooledDirectByteBuf>() {

        @Override
        public PooledDirectByteBuf newObject(Handle<PooledDirectByteBuf> handle) {
            return new PooledDirectByteBuf(handle, 0);
        }
    });

    static PooledDirectByteBuf newInstance(int maxCapacity) {
        PooledDirectByteBuf buf = RECYCLER.get();
        buf.reuse(maxCapacity);
        return buf;
    }

    private PooledDirectByteBuf(Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity) {
        super(recyclerHandle, maxCapacity);
    }

    @Override
    protected ByteBuffer newInternalNioBuffer(ByteBuffer memory) {
        return memory.duplicate();
    }

    @Override
    public boolean isDirect() {
        return true;
    }

    @Override
    protected byte _getByte(int index) {
        return memory.get(idx(index));
    }

    @Override
    protected short _getShort(int index) {
        return memory.getShort(idx(index));
    }

    @Override
    protected short _getShortLE(int index) {
        return ByteBufUtil.swapShort(_getShort(index));
    }

    @Override
    protected int _getUnsignedMedium(int index) {
        index = idx(index);
        return (memory.get(index) & 0xff) << 16 | (memory.get(index + 1) & 0xff) << 8 | memory.get(index + 2) & 0xff;
    }

    @Override
    protected int _getUnsignedMediumLE(int index) {
        index = idx(index);
        return memory.get(index) & 0xff | (memory.get(index + 1) & 0xff) << 8 | (memory.get(index + 2) & 0xff) << 16;
    }

    @Override
    protected int _getInt(int index) {
        return memory.getInt(idx(index));
    }

    @Override
    protected int _getIntLE(int index) {
        return ByteBufUtil.swapInt(_getInt(index));
    }

    @Override
    protected long _getLong(int index) {
        return memory.getLong(idx(index));
    }

    @Override
    protected long _getLongLE(int index) {
        return ByteBufUtil.swapLong(_getLong(index));
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.capacity());
        if (dst.hasArray()) {
            getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
        } else if (dst.nioBufferCount() > 0) {
            for (ByteBuffer bb : dst.nioBuffers(dstIndex, length)) {
                int bbLen = bb.remaining();
                getBytes(index, bb);
                index += bbLen;
            }
        } else {
            dst.setBytes(dstIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.length);
        _internalNioBuffer(index, length, true).get(dst, dstIndex, length);
        return this;
    }

    @Override
    public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
        checkDstIndex(length, dstIndex, dst.length);
        _internalNioBuffer(readerIndex, length, false).get(dst, dstIndex, length);
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuffer dst) {
        dst.put(duplicateInternalNioBuffer(index, dst.remaining()));
        return this;
    }

    @Override
    public ByteBuf readBytes(ByteBuffer dst) {
        int length = dst.remaining();
        checkReadableBytes(length);
        dst.put(_internalNioBuffer(readerIndex, length, false));
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
        getBytes(index, out, length, false);
        return this;
    }

    private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException {
        checkIndex(index, length);
        if (length == 0) {
            return;
        }
        ByteBufUtil.readBytes(alloc(), internal ? internalNioBuffer() : memory.duplicate(), idx(index), length, out);
    }

    @Override
    public ByteBuf readBytes(OutputStream out, int length) throws IOException {
        checkReadableBytes(length);
        getBytes(readerIndex, out, length, true);
        readerIndex += length;
        return this;
    }

    @Override
    protected void _setByte(int index, int value) {
        memory.put(idx(index), (byte) value);
    }

    @Override
    protected void _setShort(int index, int value) {
        memory.putShort(idx(index), (short) value);
    }

    @Override
    protected void _setShortLE(int index, int value) {
        _setShort(index, ByteBufUtil.swapShort((short) value));
    }

    @Override
    protected void _setMedium(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) (value >>> 16));
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) value);
    }

    @Override
    protected void _setMediumLE(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) value);
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) (value >>> 16));
    }

    @Override
    protected void _setInt(int index, int value) {
        memory.putInt(idx(index), value);
    }

    @Override
    protected void _setIntLE(int index, int value) {
        _setInt(index, ByteBufUtil.swapInt(value));
    }

    @Override
    protected void _setLong(int index, long value) {
        memory.putLong(idx(index), value);
    }

    @Override
    protected void _setLongLE(int index, long value) {
        _setLong(index, ByteBufUtil.swapLong(value));
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.capacity());
        if (src.hasArray()) {
            setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
        } else if (src.nioBufferCount() > 0) {
            for (ByteBuffer bb : src.nioBuffers(srcIndex, length)) {
                int bbLen = bb.remaining();
                setBytes(index, bb);
                index += bbLen;
            }
        } else {
            src.getBytes(srcIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.length);
        _internalNioBuffer(index, length, false).put(src, srcIndex, length);
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuffer src) {
        int length = src.remaining();
        checkIndex(index, length);
        ByteBuffer tmpBuf = internalNioBuffer();
        if (src == tmpBuf) {
            src = src.duplicate();
        }
        index = idx(index);
        tmpBuf.limit(index + length).position(index);
        tmpBuf.put(src);
        return this;
    }

    @Override
    public int setBytes(int index, InputStream in, int length) throws IOException {

        if (readBytes <= 0) {
            return readBytes;
        }
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.position(idx(index));
        tmpBuf.put(tmp, 0, readBytes);
        return readBytes;
    }

    @Override
    public ByteBuf copy(int index, int length) {
        checkIndex(index, length);
        ByteBuf copy = alloc().directBuffer(length, maxCapacity());
        return copy.writeBytes(this, index, length);
    }

    @Override
    public boolean hasArray() {
        return false;
    }

    @Override
    public byte[] array() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public int arrayOffset() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public boolean hasMemoryAddress() {
        return false;
    }

    @Override
    public long memoryAddress() {
        throw new UnsupportedOperationException();
    }
}


if (readBytes <= 0) {
            return readBytes;
        }
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.position(idx(index));

package io.netty.buffer;

import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.ObjectCreator;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;

final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {

    private static final ObjectPool<PooledDirectByteBuf> RECYCLER = ObjectPool.newPool(new ObjectCreator<PooledDirectByteBuf>() {

        @Override
        public PooledDirectByteBuf newObject(Handle<PooledDirectByteBuf> handle) {
            return new PooledDirectByteBuf(handle, 0);
        }
    });

    static PooledDirectByteBuf newInstance(int maxCapacity) {
        PooledDirectByteBuf buf = RECYCLER.get();
        buf.reuse(maxCapacity);
        return buf;
    }

    private PooledDirectByteBuf(Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity) {
        super(recyclerHandle, maxCapacity);
    }

    @Override
    protected ByteBuffer newInternalNioBuffer(ByteBuffer memory) {
        return memory.duplicate();
    }

    @Override
    public boolean isDirect() {
        return true;
    }

    @Override
    protected byte _getByte(int index) {
        return memory.get(idx(index));
    }

    @Override
    protected short _getShort(int index) {
        return memory.getShort(idx(index));
    }

    @Override
    protected short _getShortLE(int index) {
        return ByteBufUtil.swapShort(_getShort(index));
    }

    @Override
    protected int _getUnsignedMedium(int index) {
        index = idx(index);
        return (memory.get(index) & 0xff) << 16 | (memory.get(index + 1) & 0xff) << 8 | memory.get(index + 2) & 0xff;
    }

    @Override
    protected int _getUnsignedMediumLE(int index) {
        index = idx(index);
        return memory.get(index) & 0xff | (memory.get(index + 1) & 0xff) << 8 | (memory.get(index + 2) & 0xff) << 16;
    }

    @Override
    protected int _getInt(int index) {
        return memory.getInt(idx(index));
    }

    @Override
    protected int _getIntLE(int index) {
        return ByteBufUtil.swapInt(_getInt(index));
    }

    @Override
    protected long _getLong(int index) {
        return memory.getLong(idx(index));
    }

    @Override
    protected long _getLongLE(int index) {
        return ByteBufUtil.swapLong(_getLong(index));
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.capacity());
        if (dst.hasArray()) {
            getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
        } else if (dst.nioBufferCount() > 0) {
            for (ByteBuffer bb : dst.nioBuffers(dstIndex, length)) {
                int bbLen = bb.remaining();
                getBytes(index, bb);
                index += bbLen;
            }
        } else {
            dst.setBytes(dstIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
        checkDstIndex(index, length, dstIndex, dst.length);
        _internalNioBuffer(index, length, true).get(dst, dstIndex, length);
        return this;
    }

    @Override
    public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
        checkDstIndex(length, dstIndex, dst.length);
        _internalNioBuffer(readerIndex, length, false).get(dst, dstIndex, length);
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, ByteBuffer dst) {
        dst.put(duplicateInternalNioBuffer(index, dst.remaining()));
        return this;
    }

    @Override
    public ByteBuf readBytes(ByteBuffer dst) {
        int length = dst.remaining();
        checkReadableBytes(length);
        dst.put(_internalNioBuffer(readerIndex, length, false));
        readerIndex += length;
        return this;
    }

    @Override
    public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
        getBytes(index, out, length, false);
        return this;
    }

    private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException {
        checkIndex(index, length);
        if (length == 0) {
            return;
        }
        ByteBufUtil.readBytes(alloc(), internal ? internalNioBuffer() : memory.duplicate(), idx(index), length, out);
    }

    @Override
    public ByteBuf readBytes(OutputStream out, int length) throws IOException {
        checkReadableBytes(length);
        getBytes(readerIndex, out, length, true);
        readerIndex += length;
        return this;
    }

    @Override
    protected void _setByte(int index, int value) {
        memory.put(idx(index), (byte) value);
    }

    @Override
    protected void _setShort(int index, int value) {
        memory.putShort(idx(index), (short) value);
    }

    @Override
    protected void _setShortLE(int index, int value) {
        _setShort(index, ByteBufUtil.swapShort((short) value));
    }

    @Override
    protected void _setMedium(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) (value >>> 16));
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) value);
    }

    @Override
    protected void _setMediumLE(int index, int value) {
        index = idx(index);
        memory.put(index, (byte) value);
        memory.put(index + 1, (byte) (value >>> 8));
        memory.put(index + 2, (byte) (value >>> 16));
    }

    @Override
    protected void _setInt(int index, int value) {
        memory.putInt(idx(index), value);
    }

    @Override
    protected void _setIntLE(int index, int value) {
        _setInt(index, ByteBufUtil.swapInt(value));
    }

    @Override
    protected void _setLong(int index, long value) {
        memory.putLong(idx(index), value);
    }

    @Override
    protected void _setLongLE(int index, long value) {
        _setLong(index, ByteBufUtil.swapLong(value));
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.capacity());
        if (src.hasArray()) {
            setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
        } else if (src.nioBufferCount() > 0) {
            for (ByteBuffer bb : src.nioBuffers(srcIndex, length)) {
                int bbLen = bb.remaining();
                setBytes(index, bb);
                index += bbLen;
            }
        } else {
            src.getBytes(srcIndex, this, index, length);
        }
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
        checkSrcIndex(index, length, srcIndex, src.length);
        _internalNioBuffer(index, length, false).put(src, srcIndex, length);
        return this;
    }

    @Override
    public ByteBuf setBytes(int index, ByteBuffer src) {
        int length = src.remaining();
        checkIndex(index, length);
        ByteBuffer tmpBuf = internalNioBuffer();
        if (src == tmpBuf) {
            src = src.duplicate();
        }
        index = idx(index);
        tmpBuf.limit(index + length).position(index);
        tmpBuf.put(src);
        return this;
    }

    @Override
    public int setBytes(int index, InputStream in, int length) throws IOException {
        checkIndex(index, length);
        byte[] tmp = ByteBufUtil.threadLocalTempArray(length);
        int readBytes = in.read(tmp, 0, length);

        tmpBuf.put(tmp, 0, readBytes);
        return readBytes;
    }

    @Override
    public ByteBuf copy(int index, int length) {
        checkIndex(index, length);
        ByteBuf copy = alloc().directBuffer(length, maxCapacity());
        return copy.writeBytes(this, index, length);
    }

    @Override
    public boolean hasArray() {
        return false;
    }

    @Override
    public byte[] array() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public int arrayOffset() {
        throw new UnsupportedOperationException("direct buffer");
    }

    @Override
    public boolean hasMemoryAddress() {
        return false;
    }

    @Override
    public long memoryAddress() {
        throw new UnsupportedOperationException();
    }
}