All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vendasta.accountgroup.v1.internal.Snapshots Maven / Gradle / Ivy

The newest version!
package com.vendasta.accountgroup.v1.internal;

import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
import java.util.Arrays;
import java.time.Duration;
import org.apache.commons.lang3.StringUtils;
import com.vendasta.accountgroup.v1.generated.ApiProto;

/**
 * 
 **/
public final class Snapshots {



	/**
	 * 
	 **/
	public static final class Snapshot {
	
	
	
	
		private final String snapshotId;
		private final Date created;
		private final Date expiry;
		
	
		private Snapshot (
			final String snapshotId,
			final Date created,
			final Date expiry)
			
		{
			this.snapshotId = snapshotId;
			this.created = created;
			this.expiry = expiry;
			
		}
		
		/**
		 * 
	      * @return The final value of snapshotId on the object
		 **/
		public String getSnapshotId() {
			return this.snapshotId;
		}
		
		/**
		 * 
	      * @return The final value of created on the object
		 **/
		public Date getCreated() {
			return this.created;
		}
		
		/**
		 * 
	      * @return The final value of expiry on the object
		 **/
		public Date getExpiry() {
			return this.expiry;
		}
		
	
		public static class Builder {
			private String snapshotId;
			private Date created;
			private Date expiry;
			
			public Builder() {
				this.snapshotId = "";
				this.created = null;
				this.expiry = null;
				
			}
			
			/**
			  * Adds a value to the builder for snapshotId
			  * @param snapshotId Value to assign to the mutable Builder
			  * @return The Builder instance so that call chaining works
			 **/
			public Builder setSnapshotId(String snapshotId) {
				this.snapshotId = snapshotId;
				return this;
			}
			
			/**
			  * Adds a value to the builder for created
			  * @param created Value to assign to the mutable Builder
			  * @return The Builder instance so that call chaining works
			 **/
			public Builder setCreated(Date created) {
				this.created = created;
				return this;
			}
			
			/**
			  * Adds a value to the builder for expiry
			  * @param expiry Value to assign to the mutable Builder
			  * @return The Builder instance so that call chaining works
			 **/
			public Builder setExpiry(Date expiry) {
				this.expiry = expiry;
				return this;
			}
			
			/**
			  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
			  * of the Snapshot class
			  * @return The instantiated final Snapshot
			 **/
			public Snapshot build() {
				return new Snapshot(
					this.snapshotId,
					this.created,
					this.expiry);
			}
		}
	
		/**
		 * Returns a Builder for Snapshot, which is a mutable representation of the object.  Once the
		 * client has built up an object they can then create an immutable Snapshot object using the
		 * build function.
		 * @return A fresh Builder instance with no values set
		 **/
		public static Builder newBuilder() {
			return new Builder();
		}
	
		/**
		 * Provides a human-readable representation of this object.  Useful for debugging.
		 * @return A string representation of the Snapshot instance
		 **/
		 public String toString() {
			 String result = "Snapshot\n";
			 result += "-> snapshotId: (String)"
			     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.snapshotId).split("\n"))) + "\n"; 
			 result += "-> created: (Date)"
			     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.created).split("\n"))) + "\n"; 
			 result += "-> expiry: (Date)"
			     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.expiry).split("\n"))) + "\n"; 
			 
			 return result;
		 }
		/**
		* Allows for simple conversion between the low-level generated protobuf object to
		* Snapshot, which is much more usable.
		* @return An instance of Snapshot representing the input proto object
		**/
		public static Snapshot fromProto(ApiProto.Snapshots.Snapshot proto) {
			Snapshot out = null;
			if (proto != null) {
				Snapshot.Builder outBuilder = Snapshot.newBuilder()
				.setSnapshotId(proto.getSnapshotId())
				.setCreated(proto.hasCreated()?new Date(proto.getCreated().getSeconds() * 1000):null)
				.setExpiry(proto.hasExpiry()?new Date(proto.getExpiry().getSeconds() * 1000):null);
				out = outBuilder.build();
			}
			return out;
		}
	
		/**
		* Convenience method for handling lists of proto objects.  It calls .fromProto on each one
		* and returns a list of the converted results.
		* @return A list of Snapshot instances representing the input proto objects
		**/
		public static List fromProtos(List protos) {
			List out = new ArrayList();
			for(ApiProto.Snapshots.Snapshot proto : protos) {
				out.add(Snapshot.fromProto(proto));
			}
			return out;
		}
	
		/**
		 * Allows for simple conversion of an object to the low-level generated protobuf object.
		 * @return An instance of ApiProto.Snapshots.Snapshot which is a proto object ready for wire transmission
		 **/
		 public ApiProto.Snapshots.Snapshot toProto() {
			 Snapshot obj = this;
			 ApiProto.Snapshots.Snapshot.Builder outBuilder = ApiProto.Snapshots.Snapshot.newBuilder();
			 outBuilder.setSnapshotId(obj.getSnapshotId());
			 if(obj.getCreated()!=null){outBuilder.setCreated(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getCreated().getTime() / 1000).build());}
			 if(obj.getExpiry()!=null){outBuilder.setExpiry(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getExpiry().getTime() / 1000).build());}
			 return outBuilder.build();
		 }
	
		 /**
		  * Convenience method for handling lists of objects.  It calls .toProto on each one and
		  * returns a list of the converted results.
		  * @return A list of ApiProto.Snapshots.Snapshot instances representing the input objects.
		  */
		public static List toProtos(List objects) {
			List out = new ArrayList();
			if(objects != null) {
				for (Snapshot obj : objects) {
					out.add(obj!=null?obj.toProto():null);
				}
			}
			return out;
		}
	}

	private final List snapshots;
	

	private Snapshots (
		final List snapshots)
		
	{
		this.snapshots = snapshots;
		
	}
	
	/**
	 * 
      * @return The final value of snapshots on the object
	 **/
	public List getSnapshots() {
		return this.snapshots;
	}
	

	public static class Builder {
		private List snapshots;
		
		public Builder() {
			this.snapshots = null;
			
		}
		
		/**
		  * Adds a value to the builder for snapshots
		  * @param snapshots Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setSnapshots(List snapshots) {
			this.snapshots = snapshots;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the Snapshots class
		  * @return The instantiated final Snapshots
		 **/
		public Snapshots build() {
			return new Snapshots(
				this.snapshots);
		}
	}

	/**
	 * Returns a Builder for Snapshots, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable Snapshots object using the
	 * build function.
	 * @return A fresh Builder instance with no values set
	 **/
	public static Builder newBuilder() {
		return new Builder();
	}

	/**
	 * Provides a human-readable representation of this object.  Useful for debugging.
	 * @return A string representation of the Snapshots instance
	 **/
	 public String toString() {
		 String result = "Snapshots\n";
		 result += "-> snapshots: (List)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.snapshots).split("\n"))) + "\n"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* Snapshots, which is much more usable.
	* @return An instance of Snapshots representing the input proto object
	**/
	public static Snapshots fromProto(ApiProto.Snapshots proto) {
		Snapshots out = null;
		if (proto != null) {
			Snapshots.Builder outBuilder = Snapshots.newBuilder()
			.setSnapshots(Snapshots.Snapshot.fromProtos(proto.getSnapshotsList()));
			out = outBuilder.build();
		}
		return out;
	}

	/**
	* Convenience method for handling lists of proto objects.  It calls .fromProto on each one
	* and returns a list of the converted results.
	* @return A list of Snapshots instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(ApiProto.Snapshots proto : protos) {
			out.add(Snapshots.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of ApiProto.Snapshots which is a proto object ready for wire transmission
	 **/
	 public ApiProto.Snapshots toProto() {
		 Snapshots obj = this;
		 ApiProto.Snapshots.Builder outBuilder = ApiProto.Snapshots.newBuilder();
		 outBuilder.addAllSnapshots(Snapshots.Snapshot.toProtos(obj.getSnapshots()));
		 return outBuilder.build();
	 }

	 /**
	  * Convenience method for handling lists of objects.  It calls .toProto on each one and
	  * returns a list of the converted results.
	  * @return A list of ApiProto.Snapshots instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (Snapshots obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy