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

com.vendasta.accountgroup.v1.internal.Activation 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;

/**
 * The information needed to activate an app
 **/
public final class Activation {




	private final AppKey appKey;
	private final boolean isTrial;
	

	private Activation (
		final AppKey appKey,
		final boolean isTrial)
		
	{
		this.appKey = appKey;
		this.isTrial = isTrial;
		
	}
	
	/**
	 * 
      * @return The final value of appKey on the object
	 **/
	public AppKey getAppKey() {
		return this.appKey;
	}
	
	/**
	 * 
      * @return The final value of isTrial on the object
	 **/
	public boolean getIsTrial() {
		return this.isTrial;
	}
	

	public static class Builder {
		private AppKey appKey;
		private boolean isTrial;
		
		public Builder() {
			this.appKey = null;
			this.isTrial = false;
			
		}
		
		/**
		  * Adds a value to the builder for appKey
		  * @param appKey Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setAppKey(AppKey appKey) {
			this.appKey = appKey;
			return this;
		}
		
		/**
		  * Adds a value to the builder for isTrial
		  * @param isTrial Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setIsTrial(boolean isTrial) {
			this.isTrial = isTrial;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the Activation class
		  * @return The instantiated final Activation
		 **/
		public Activation build() {
			return new Activation(
				this.appKey,
				this.isTrial);
		}
	}

	/**
	 * Returns a Builder for Activation, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable Activation 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 Activation instance
	 **/
	 public String toString() {
		 String result = "Activation\n";
		 result += "-> appKey: (AppKey)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.appKey).split("\n"))) + "\n"; 
		 result += "-> isTrial: (boolean)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.isTrial).split("\n"))) + "\n"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* Activation, which is much more usable.
	* @return An instance of Activation representing the input proto object
	**/
	public static Activation fromProto(ApiProto.Activation proto) {
		Activation out = null;
		if (proto != null) {
			Activation.Builder outBuilder = Activation.newBuilder()
			.setAppKey(AppKey.fromProto(proto.getAppKey()))
			.setIsTrial(proto.getIsTrial());
			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 Activation instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(ApiProto.Activation proto : protos) {
			out.add(Activation.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of ApiProto.Activation which is a proto object ready for wire transmission
	 **/
	 public ApiProto.Activation toProto() {
		 Activation obj = this;
		 ApiProto.Activation.Builder outBuilder = ApiProto.Activation.newBuilder();
		 if(obj.getAppKey() != null){outBuilder.setAppKey(obj.getAppKey().toProto());}
		 outBuilder.setIsTrial(obj.getIsTrial());
		 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.Activation instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (Activation obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy