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;
 
 
Class Snapshot

Author(s):
Richard Downer
 
 public class Snapshot {

   
 
    public static enum State {
 
       BACKED_UP, CREATING, BACKING_UP, 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 {
 
       MANUAL, RECURRING, UNRECOGNIZED;
 
       public static Type fromValue(String type) {
          try {
             return valueOf(checkNotNull(type"type"));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
    }

   
 
    public static enum Interval {
 
       HOURLY, DAILY, WEEKLY, MONTHLY, template, none, UNRECOGNIZED;
 
       public static Interval fromValue(String type) {
          try {
             return valueOf(checkNotNull(type"type"));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
    }
 
    public static Builder<?> builder() {
       return new ConcreteBuilder();
    }
 
    public Builder<?> toBuilder() {
       return new ConcreteBuilder().fromSnapshot(this);
    }
 
    public abstract static class Builder<T extends Builder<T>> {
       protected abstract T self();
 
       protected String id;
       protected String account;
      protected Date created;
      protected String domain;
      protected String domainId;
      protected Snapshot.Interval interval;
      protected String jobId;
      protected String jobStatus;
      protected String name;
      protected Snapshot.Type snapshotType;
      protected Snapshot.State state;
      protected String volumeId;
      protected String volumeName;
      protected Volume.Type volumeType;

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

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

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

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

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

      
      public T interval(Snapshot.Interval interval) {
         this. = interval;
         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 snapshotType(Snapshot.Type snapshotType) {
         this. = snapshotType;
         return self();
      }

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

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

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

      
      public T volumeType(Volume.Type volumeType) {
         this. = volumeType;
         return self();
      }
      public Snapshot build() {
         return new Snapshot(,
               );
      }
      public T fromSnapshot(Snapshot in) {
         return this
               .id(in.getId())
               .account(in.getAccount())
               .created(in.getCreated())
               .domain(in.getDomain())
               .domainId(in.getDomainId())
               .interval(in.getInterval())
               .jobId(in.getJobId())
               .jobStatus(in.getJobStatus())
               .name(in.getName())
               .snapshotType(in.getSnapshotType())
               .state(in.getState())
               .volumeId(in.getVolumeId())
               .volumeName(in.getVolumeName())
               .volumeType(in.getVolumeType());
      }
   }
   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
      @Override
      protected ConcreteBuilder self() {
         return this;
      }
   }
   private final String id;
   private final String account;
   private final Date created;
   private final String domain;
   private final String domainId;
   private final Snapshot.Interval interval;
   private final String jobId;
   private final String jobStatus;
   private final String name;
   private final Snapshot.Type snapshotType;
   private final Snapshot.State state;
   private final String volumeId;
   private final String volumeName;
   private final Volume.Type volumeType;
         "id""account""created""domain""domainid""intervaltype""jobid""jobstatus""name""snapshottype""state""volumeid""volumename""volumetype"
   })
   protected Snapshot(String id, @Nullable String account, @Nullable Date created, @Nullable String domain, @Nullable String domainId,
                      @Nullable Snapshot.Interval interval, @Nullable String jobId, @Nullable String jobStatus, @Nullable String name,
                      @Nullable Snapshot.Type snapshotType, @Nullable Snapshot.State state, @Nullable String volumeId, @Nullable String volumeName,
                      @Nullable Volume.Type volumeType) {
      this. = checkNotNull(id"id");
      this. = account;
      this. = created;
      this. = domain;
      this. = domainId;
      this. = interval;
      this. = jobId;
      this. = jobStatus;
      this. = name;
      this. = snapshotType;
      this. = state;
      this. = volumeId;
      this. = volumeName;
      this. = volumeType;
   }

   

Returns:
ID of the snapshot
   public String getId() {
      return this.;
   }

   

Returns:
the account associated with the snapshot
   public String getAccount() {
      return this.;
   }

   

Returns:
the date the snapshot was created
   public Date getCreated() {
      return this.;
   }

   

Returns:
the domain name of the snapshot's account
   public String getDomain() {
      return this.;
   }

   

Returns:
the domain ID of the snapshot's account
   public String getDomainId() {
      return this.;
   }

   

Returns:
valid types are hourly, daily, weekly, monthly, template, and none.
   public Snapshot.Interval getInterval() {
      return this.;
   }

   

Returns:
the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
   public String getJobId() {
      return this.;
   }

   

Returns:
the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
   public String getJobStatus() {
      return this.;
   }

   

Returns:
name of the snapshot
   public String getName() {
      return this.;
   }

   

Returns:
the type of the snapshot
   public Snapshot.Type getSnapshotType() {
      return this.;
   }

   

Returns:
the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage
   public Snapshot.State getState() {
      return this.;
   }

   

Returns:
ID of the disk volume
   public String getVolumeId() {
      return this.;
   }

   

Returns:
name of the disk volume
   public String getVolumeName() {
      return this.;
   }

   

Returns:
type of the disk volume
   public Volume.Type getVolumeType() {
      return this.;
   }
   public int hashCode() {
   }
   public boolean equals(Object obj) {
      if (this == objreturn true;
      if (obj == null || getClass() != obj.getClass()) return false;
      Snapshot that = Snapshot.class.cast(obj);
      return Objects.equal(this.that.id)
            && Objects.equal(this.that.account)
            && Objects.equal(this.that.created)
            && Objects.equal(this.that.domain)
            && Objects.equal(this.that.domainId)
            && Objects.equal(this.that.interval)
            && Objects.equal(this.that.jobId)
            && Objects.equal(this.that.jobStatus)
            && Objects.equal(this.that.name)
            && Objects.equal(this.that.snapshotType)
            && Objects.equal(this.that.state)
            && Objects.equal(this.that.volumeId)
            && Objects.equal(this.that.volumeName)
            && Objects.equal(this.that.volumeType);
   }
   protected ToStringHelper string() {
      return Objects.toStringHelper(this)
            .add("id").add("account").add("created").add("domain").add("domainId")
            .add("interval").add("jobId").add("jobStatus").add("name").add("snapshotType")
            .add("state").add("volumeId").add("volumeName").add("volumeType");
   }
   public String toString() {
      return string().toString();
   }
New to GrepCode? Check out our FAQ X