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

com.vendasta.salesorders.v1.internal.AddonActivation Maven / Gradle / Ivy

The newest version!
package com.vendasta.salesorders.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 org.apache.commons.lang3.StringUtils;
import com.vendasta.salesorders.v1.generated.SalesOrdersProto;

/**
 * Represents a single addon with its corresponding activation status
 **/
public final class AddonActivation {




	private final String addonId;
	private final String appId;
	private final ActivationStatus activationStatus;
	

	private AddonActivation (
		final String addonId,
		final String appId,
		final ActivationStatus activationStatus)
		
	{
		this.addonId = addonId;
		this.appId = appId;
		this.activationStatus = activationStatus;
		
	}
	
	/**
	 * Unique identifier of a single addon that is going through the activation process
      * @return The final value of addonId on the object
	 **/
	public String getAddonId() {
		return this.addonId;
	}
	
	/**
	 * Unique identifier of the parent app for the addon that is going through the activation process
      * @return The final value of appId on the object
	 **/
	public String getAppId() {
		return this.appId;
	}
	
	/**
	 * The activation status of a single product
      * @return The final value of activationStatus on the object
	 **/
	public ActivationStatus getActivationStatus() {
		return this.activationStatus;
	}
	

	public static class Builder {
		private String addonId;
		private String appId;
		private ActivationStatus activationStatus;
		
		public Builder() {
			this.addonId = "";
			this.appId = "";
			this.activationStatus = null;
			
		}
		
		/**
		  * Adds a value to the builder for addonId
		  * @param addonId Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setAddonId(String addonId) {
			this.addonId = addonId;
			return this;
		}
		
		/**
		  * Adds a value to the builder for appId
		  * @param appId Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setAppId(String appId) {
			this.appId = appId;
			return this;
		}
		
		/**
		  * Adds a value to the builder for activationStatus
		  * @param activationStatus Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setActivationStatus(ActivationStatus activationStatus) {
			this.activationStatus = activationStatus;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the AddonActivation class
		  * @return The instantiated final AddonActivation
		 **/
		public AddonActivation build() {
			return new AddonActivation(
				this.addonId,
				this.appId,
				this.activationStatus);
		}
	}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy