Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jclouds.cloudstack.domain;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Date;
 import java.util.Map;
 
 

Author(s):
Vijay Kiran
 
 public class Volume {

   
 
    public static enum State {

      
indicates that the volume record is created in the DB, but not on the backend
 
       ALLOCATED,
      
the volume is being created on the backend
 
       CREATING,
      
the volume is ready to be used
 
       READY,
      
the volume is destroyed (either as a result of deleteVolume command for DataDisk or as a part of destroyVm)
 
       DESTROYED,
      
the volume has failed somehow, e.g. during creation (in cloudstack development)
 
       FAILED,
 
       UNRECOGNIZED;
 
       @Override
       public String toString() {
          return ..to(.name());
       }
 
       public static State fromValue(String state) {
          try {
             return valueOf(..to(.checkNotNull(state"state")));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
    }

   
 
    public static enum Type {
       ROOT(0),
       DATADISK(1),
       UNRECOGNIZED(.);
 
       private int code;
 
       private static final Map<IntegerTypeINDEX = Maps.uniqueIndex(ImmutableSet.copyOf(Type.values()),
             new Function<TypeInteger>() {
 
                @Override
                public Integer apply(Type input) {
                   return input.code;
                }
 
             });
 
       Type(int code) {
         this. = code;
      }
      @Override
      public String toString() {
         return name().toLowerCase();
      }
      public static Type fromValue(String resourceType) {
         Integer code = Integer.valueOf(checkNotNull(resourceType"resourcetype"));
         return .containsKey(code) ? .get(code) : ;
      }
   }
   public static Builder<?> builder() {
      return new ConcreteBuilder();
   }
   public Builder<?> toBuilder() {
      return new ConcreteBuilder().fromVolume(this);
   }
   public abstract static class Builder<T extends Builder<T>> {
      protected abstract T self();
      protected String id;
      protected String account;
      protected Date attached;
      protected Date created;
      protected boolean destroyed;
      protected String deviceId;
      protected String diskOfferingDisplayText;
      protected String diskOfferingId;
      protected String diskOfferingName;
      protected String domain;
      protected String domainId;
      protected String hypervisor;
      protected boolean isExtractable;
      protected String jobId;
      protected String jobStatus;
      protected String name;
      protected String serviceOfferingDisplayText;
      protected String serviceOfferingId;
      protected String serviceOfferingName;
      protected long size;
      protected String snapshotId;
      protected Volume.State state;
      protected String storage;
      protected String storageType;
      protected Volume.Type type;
      protected String virtualMachineId;
      protected String vmDisplayName;
      protected String vmName;
      protected VirtualMachine.State vmState;
      protected String zoneId;
      protected String zoneName;

      

See also:
Volume.getId()
      public T id(String id) {
         this. = id;
         return self();
      }

      
      public T account(String account) {
         this. = account;
         return self();
      }

      
      public T attached(Date attached) {
         this. = attached;
         return self();
      }

      
      public T created(Date created) {
         this. = created;
         return self();
      }

      
      public T destroyed(boolean destroyed) {
         this. = destroyed;
         return self();
      }

      
      public T deviceId(String deviceId) {
         this. = deviceId;
         return self();
      }

      
      public T diskOfferingDisplayText(String diskOfferingDisplayText) {
         this. = diskOfferingDisplayText;
         return self();
      }

      
      public T diskOfferingId(String diskOfferingId) {
         this. = diskOfferingId;
         return self();
      }

      
      public T diskOfferingName(String diskOfferingName) {
         this. = diskOfferingName;
         return self();
      }

      
      public T domain(String domain) {
         this. = domain;
         return self();
      }

      
      public T domainId(String domainId) {
         this. = domainId;
         return self();
      }

      
      public T hypervisor(String hypervisor) {
         this. = hypervisor;
         return self();
      }

      
      public T isExtractable(boolean isExtractable) {
         this. = isExtractable;
         return self();
      }

      
      public T jobId(String jobId) {
         this. = jobId;
         return self();
      }

      
      public T jobStatus(String jobStatus) {
         this. = jobStatus;
         return self();
      }

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

      
      public T serviceOfferingDisplayText(String serviceOfferingDisplayText) {
         this. = serviceOfferingDisplayText;
         return self();
      }

      
      public T serviceOfferingId(String serviceOfferingId) {
         this. = serviceOfferingId;
         return self();
      }

      
      public T serviceOfferingName(String serviceOfferingName) {
         this. = serviceOfferingName;
         return self();
      }

      
      public T size(long size) {
         this. = size;
         return self();
      }

      
      public T snapshotId(String snapshotId) {
         this. = snapshotId;
         return self();
      }

      
      public T state(Volume.State state) {
         this. = state;
         return self();
      }

      
      public T storage(String storage) {
         this. = storage;
         return self();
      }

      
      public T storageType(String storageType) {
         this. = storageType;
         return self();
      }

      
      public T type(Volume.Type type) {
         this. = type;
         return self();
      }

      
      public T virtualMachineId(String virtualMachineId) {
         this. = virtualMachineId;
         return self();
      }

      
      public T vmDisplayName(String vmDisplayName) {
         this. = vmDisplayName;
         return self();
      }

      
      public T vmName(String vmName) {
         this. = vmName;
         return self();
      }

      
      public T vmState(VirtualMachine.State vmState) {
         this. = vmState;
         return self();
      }

      
      public T zoneId(String zoneId) {
         this. = zoneId;
         return self();
      }

      
      public T zoneName(String zoneName) {
         this. = zoneName;
         return self();
      }
      public Volume build() {
      }
      public T fromVolume(Volume in) {
         return this
               .id(in.getId())
               .account(in.getAccount())
               .attached(in.getAttached())
               .created(in.getCreated())
               .destroyed(in.isDestroyed())
               .deviceId(in.getDeviceId())
               .diskOfferingDisplayText(in.getDiskOfferingDisplayText())
               .diskOfferingId(in.getDiskOfferingId())
               .diskOfferingName(in.getDiskOfferingName())
               .domain(in.getDomain())
               .domainId(in.getDomainId())
               .hypervisor(in.getHypervisor())
               .isExtractable(in.isExtractable())
               .jobId(in.getJobId())
               .jobStatus(in.getJobStatus())
               .name(in.getName())
               .serviceOfferingId(in.getServiceOfferingId())
               .serviceOfferingName(in.getServiceOfferingName())
               .size(in.getSize())
               .snapshotId(in.getSnapshotId())
               .state(in.getState())
               .storage(in.getStorage())
               .storageType(in.getStorageType())
               .type(in.getType())
               .virtualMachineId(in.getVirtualMachineId())
               .vmDisplayName(in.getVmDisplayName())
               .vmName(in.getVmName())
               .vmState(in.getVmState())
               .zoneId(in.getZoneId())
               .zoneName(in.getZoneName());
      }
   }
   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
      @Override
      protected ConcreteBuilder self() {
         return this;
      }
   }
   private final String id;
   private final String account;
   private final Date attached;
   private final Date created;
   private final boolean destroyed;
   private final String deviceId;
   private final String diskOfferingDisplayText;
   private final String diskOfferingId;
   private final String diskOfferingName;
   private final String domain;
   private final String domainId;
   private final String hypervisor;
   private final boolean isExtractable;
   private final String jobId;
   private final String jobStatus;
   private final String name;
   private final String serviceOfferingDisplayText;
   private final String serviceOfferingId;
   private final String serviceOfferingName;
   private final long size;
   private final String snapshotId;
   private final Volume.State state;
   private final String storage;
   private final String storageType;
   private final Volume.Type type;
   private final String virtualMachineId;
   private final String vmDisplayName;
   private final String vmName;
   private final VirtualMachine.State vmState;
   private final String zoneId;
   private final String zoneName;
         "id""account""attached""created""destroyed""deviceid""diskofferingdisplaytext""diskofferingid""diskofferingname""domain""domainid""hypervisor""isextractable""jobid""jobstatus""name""serviceofferingdisplaytext""serviceofferingid""serviceofferingname""size""snapshotid""state""storage""storagetype""type""virtualmachineid""vmdisplayname""vmname""vmstate""zoneid""zonename"
   })
   protected Volume(String id, @Nullable String account, @Nullable Date attached, @Nullable Date createdboolean destroyed,
                    @Nullable String deviceId, @Nullable String diskOfferingDisplayText, @Nullable String diskOfferingId,
                    @Nullable String diskOfferingName, @Nullable String domain, @Nullable String domainId, @Nullable String hypervisor,
                    boolean isExtractable, @Nullable String jobId, @Nullable String jobStatus, @Nullable String name,
                    @Nullable String serviceOfferingDisplayText, @Nullable String serviceOfferingId, @Nullable String serviceOfferingName,
                    long size, @Nullable String snapshotId, @Nullable Volume.State state, @Nullable String storage,
                    @Nullable String storageType, @Nullable Volume.Type type, @Nullable String virtualMachineId,
                    @Nullable String vmDisplayName, @Nullable String vmName, @Nullable VirtualMachine.State vmState,
                    @Nullable String zoneId, @Nullable String zoneName) {
      this. = checkNotNull(id"id");
      this. = account;
      this. = attached;
      this. = created;
      this. = destroyed;
      this. = deviceId;
      this. = diskOfferingDisplayText;
      this. = diskOfferingId;
      this. = diskOfferingName;
      this. = domain;
      this. = domainId;
      this. = hypervisor;
      this. = isExtractable;
      this. = jobId;
      this. = jobStatus;
      this. = name;
      this. = serviceOfferingDisplayText;
      this. = serviceOfferingId;
      this. = serviceOfferingName;
      this. = size;
      this. = snapshotId;
      this. = state;
      this. = storage;
      this. = storageType;
      this. = type;
      this. = virtualMachineId;
      this. = vmDisplayName;
      this. = vmName;
      this. = vmState;
      this. = zoneId;
      this. = zoneName;
   }
   public String getId() {
      return this.;
   }
   public String getAccount() {
      return this.;
   }
   public Date getAttached() {
      return this.;
   }
   public Date getCreated() {
      return this.;
   }
   public boolean isDestroyed() {
      return this.;
   }
   public String getDeviceId() {
      return this.;
   }
      return this.;
   }
   public String getDiskOfferingId() {
      return this.;
   }
   public String getDiskOfferingName() {
      return this.;
   }
   public String getDomain() {
      return this.;
   }
   public String getDomainId() {
      return this.;
   }
   public String getHypervisor() {
      return this.;
   }
   public boolean isExtractable() {
      return this.;
   }
   public String getJobId() {
      return this.;
   }
   public String getJobStatus() {
      return this.;
   }
   public String getName() {
      return this.;
   }
      return this.;
   }
   public String getServiceOfferingId() {
      return this.;
   }
   public String getServiceOfferingName() {
      return this.;
   }
   public long getSize() {
      return this.;
   }
   public String getSnapshotId() {
      return this.;
   }
   public Volume.State getState() {
      return this.;
   }
   public String getStorage() {
      return this.;
   }
   public String getStorageType() {
      return this.;
   }
   public Volume.Type getType() {
      return this.;
   }
   public String getVirtualMachineId() {
      return this.;
   }
   public String getVmDisplayName() {
      return this.;
   }
   public String getVmName() {
      return this.;
   }
   public VirtualMachine.State getVmState() {
      return this.;
   }
   public String getZoneId() {
      return this.;
   }
   public String getZoneName() {
      return this.;
   }
   public int hashCode() {
   }
   public boolean equals(Object obj) {
      if (this == objreturn true;
      if (obj == null || getClass() != obj.getClass()) return false;
      Volume that = Volume.class.cast(obj);
      return Objects.equal(this.that.id)
            && Objects.equal(this.that.account)
            && Objects.equal(this.that.attached)
            && Objects.equal(this.that.created)
            && Objects.equal(this.that.destroyed)
            && Objects.equal(this.that.deviceId)
            && Objects.equal(this.that.diskOfferingDisplayText)
            && Objects.equal(this.that.diskOfferingId)
            && Objects.equal(this.that.diskOfferingName)
            && Objects.equal(this.that.domain)
            && Objects.equal(this.that.domainId)
            && Objects.equal(this.that.hypervisor)
            && Objects.equal(this.that.isExtractable)
            && Objects.equal(this.that.jobId)
            && Objects.equal(this.that.jobStatus)
            && Objects.equal(this.that.name)
            && Objects.equal(this.that.serviceOfferingDisplayText)
            && Objects.equal(this.that.serviceOfferingId)
            && Objects.equal(this.that.serviceOfferingName)
            && Objects.equal(this.that.size)
            && Objects.equal(this.that.snapshotId)
            && Objects.equal(this.that.state)
            && Objects.equal(this.that.storage)
            && Objects.equal(this.that.storageType)
            && Objects.equal(this.that.type)
            && Objects.equal(this.that.virtualMachineId)
            && Objects.equal(this.that.vmDisplayName)
            && Objects.equal(this.that.vmName)
            && Objects.equal(this.that.vmState)
            && Objects.equal(this.that.zoneId)
            && Objects.equal(this.that.zoneName);
   }
   protected ToStringHelper string() {
      return Objects.toStringHelper(this)
            .add("id").add("account").add("attached").add("created").add("destroyed")
            .add("deviceId").add("diskOfferingDisplayText").add("diskOfferingId")
            .add("diskOfferingName").add("domain").add("domainId").add("hypervisor")
            .add("isExtractable").add("jobId").add("jobStatus").add("name")
            .add("serviceOfferingDisplayText").add("serviceOfferingId")
            .add("serviceOfferingName").add("size").add("snapshotId").add("state")
            .add("storage").add("storageType").add("type").add("virtualMachineId")
            .add("vmDisplayName").add("vmName").add("vmState").add("zoneId").add("zoneName");
   }
   public String toString() {
      return string().toString();
   }
New to GrepCode? Check out our FAQ X