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

com.vendasta.accountgroup.v1.internal.ListingDistributionDetails 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 ListingDistributionDetails {




	private final String orderId;
	private final String purchaseId;
	private final Date fromDate;
	private final Date thruDate;
	private final boolean autoRenew;
	

	private ListingDistributionDetails (
		final String orderId,
		final String purchaseId,
		final Date fromDate,
		final Date thruDate,
		final boolean autoRenew)
		
	{
		this.orderId = orderId;
		this.purchaseId = purchaseId;
		this.fromDate = fromDate;
		this.thruDate = thruDate;
		this.autoRenew = autoRenew;
		
	}
	
	/**
	 * 
      * @return The final value of orderId on the object
	 **/
	public String getOrderId() {
		return this.orderId;
	}
	
	/**
	 * 
      * @return The final value of purchaseId on the object
	 **/
	public String getPurchaseId() {
		return this.purchaseId;
	}
	
	/**
	 * 
      * @return The final value of fromDate on the object
	 **/
	public Date getFromDate() {
		return this.fromDate;
	}
	
	/**
	 * 
      * @return The final value of thruDate on the object
	 **/
	public Date getThruDate() {
		return this.thruDate;
	}
	
	/**
	 * 
      * @return The final value of autoRenew on the object
	 **/
	public boolean getAutoRenew() {
		return this.autoRenew;
	}
	

	public static class Builder {
		private String orderId;
		private String purchaseId;
		private Date fromDate;
		private Date thruDate;
		private boolean autoRenew;
		
		public Builder() {
			this.orderId = "";
			this.purchaseId = "";
			this.fromDate = null;
			this.thruDate = null;
			this.autoRenew = false;
			
		}
		
		/**
		  * Adds a value to the builder for orderId
		  * @param orderId Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setOrderId(String orderId) {
			this.orderId = orderId;
			return this;
		}
		
		/**
		  * Adds a value to the builder for purchaseId
		  * @param purchaseId Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setPurchaseId(String purchaseId) {
			this.purchaseId = purchaseId;
			return this;
		}
		
		/**
		  * Adds a value to the builder for fromDate
		  * @param fromDate Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setFromDate(Date fromDate) {
			this.fromDate = fromDate;
			return this;
		}
		
		/**
		  * Adds a value to the builder for thruDate
		  * @param thruDate Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setThruDate(Date thruDate) {
			this.thruDate = thruDate;
			return this;
		}
		
		/**
		  * Adds a value to the builder for autoRenew
		  * @param autoRenew Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setAutoRenew(boolean autoRenew) {
			this.autoRenew = autoRenew;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the ListingDistributionDetails class
		  * @return The instantiated final ListingDistributionDetails
		 **/
		public ListingDistributionDetails build() {
			return new ListingDistributionDetails(
				this.orderId,
				this.purchaseId,
				this.fromDate,
				this.thruDate,
				this.autoRenew);
		}
	}

	/**
	 * Returns a Builder for ListingDistributionDetails, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable ListingDistributionDetails 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 ListingDistributionDetails instance
	 **/
	 public String toString() {
		 String result = "ListingDistributionDetails\n";
		 result += "-> orderId: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.orderId).split("\n"))) + "\n"; 
		 result += "-> purchaseId: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.purchaseId).split("\n"))) + "\n"; 
		 result += "-> fromDate: (Date)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.fromDate).split("\n"))) + "\n"; 
		 result += "-> thruDate: (Date)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.thruDate).split("\n"))) + "\n"; 
		 result += "-> autoRenew: (boolean)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.autoRenew).split("\n"))) + "\n"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* ListingDistributionDetails, which is much more usable.
	* @return An instance of ListingDistributionDetails representing the input proto object
	**/
	public static ListingDistributionDetails fromProto(ApiProto.ListingDistributionDetails proto) {
		ListingDistributionDetails out = null;
		if (proto != null) {
			ListingDistributionDetails.Builder outBuilder = ListingDistributionDetails.newBuilder()
			.setOrderId(proto.getOrderId())
			.setPurchaseId(proto.getPurchaseId())
			.setFromDate(proto.hasFromDate()?new Date(proto.getFromDate().getSeconds() * 1000):null)
			.setThruDate(proto.hasThruDate()?new Date(proto.getThruDate().getSeconds() * 1000):null)
			.setAutoRenew(proto.getAutoRenew());
			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 ListingDistributionDetails instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(ApiProto.ListingDistributionDetails proto : protos) {
			out.add(ListingDistributionDetails.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of ApiProto.ListingDistributionDetails which is a proto object ready for wire transmission
	 **/
	 public ApiProto.ListingDistributionDetails toProto() {
		 ListingDistributionDetails obj = this;
		 ApiProto.ListingDistributionDetails.Builder outBuilder = ApiProto.ListingDistributionDetails.newBuilder();
		 outBuilder.setOrderId(obj.getOrderId());
		 outBuilder.setPurchaseId(obj.getPurchaseId());
		 if(obj.getFromDate()!=null){outBuilder.setFromDate(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getFromDate().getTime() / 1000).build());}
		 if(obj.getThruDate()!=null){outBuilder.setThruDate(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getThruDate().getTime() / 1000).build());}
		 outBuilder.setAutoRenew(obj.getAutoRenew());
		 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.ListingDistributionDetails instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (ListingDistributionDetails obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy