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

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

/**
 * AccountGroupHealth is the health of the account group
 **/
public final class AccountGroupHealth {




	private final double rating;
	private final String reason;
	private final String updatedBy;
	private final Date updatedOn;
	

	private AccountGroupHealth (
		final double rating,
		final String reason,
		final String updatedBy,
		final Date updatedOn)
		
	{
		this.rating = rating;
		this.reason = reason;
		this.updatedBy = updatedBy;
		this.updatedOn = updatedOn;
		
	}
	
	/**
	 * 
      * @return The final value of rating on the object
	 **/
	public double getRating() {
		return this.rating;
	}
	
	/**
	 * reason is the reason for updating the health
      * @return The final value of reason on the object
	 **/
	public String getReason() {
		return this.reason;
	}
	
	/**
	 * updated_by is the user id who updated the health rating
      * @return The final value of updatedBy on the object
	 **/
	public String getUpdatedBy() {
		return this.updatedBy;
	}
	
	/**
	 * 
      * @return The final value of updatedOn on the object
	 **/
	public Date getUpdatedOn() {
		return this.updatedOn;
	}
	

	public static class Builder {
		private double rating;
		private String reason;
		private String updatedBy;
		private Date updatedOn;
		
		public Builder() {
			this.rating = 0;
			this.reason = "";
			this.updatedBy = "";
			this.updatedOn = null;
			
		}
		
		/**
		  * Adds a value to the builder for rating
		  * @param rating Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setRating(double rating) {
			this.rating = rating;
			return this;
		}
		
		/**
		  * Adds a value to the builder for reason
		  * @param reason Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setReason(String reason) {
			this.reason = reason;
			return this;
		}
		
		/**
		  * Adds a value to the builder for updatedBy
		  * @param updatedBy Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setUpdatedBy(String updatedBy) {
			this.updatedBy = updatedBy;
			return this;
		}
		
		/**
		  * Adds a value to the builder for updatedOn
		  * @param updatedOn Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setUpdatedOn(Date updatedOn) {
			this.updatedOn = updatedOn;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the AccountGroupHealth class
		  * @return The instantiated final AccountGroupHealth
		 **/
		public AccountGroupHealth build() {
			return new AccountGroupHealth(
				this.rating,
				this.reason,
				this.updatedBy,
				this.updatedOn);
		}
	}

	/**
	 * Returns a Builder for AccountGroupHealth, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable AccountGroupHealth 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 AccountGroupHealth instance
	 **/
	 public String toString() {
		 String result = "AccountGroupHealth\n";
		 result += "-> rating: (double)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.rating).split("\n"))) + "\n"; 
		 result += "-> reason: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.reason).split("\n"))) + "\n"; 
		 result += "-> updatedBy: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.updatedBy).split("\n"))) + "\n"; 
		 result += "-> updatedOn: (Date)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.updatedOn).split("\n"))) + "\n"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* AccountGroupHealth, which is much more usable.
	* @return An instance of AccountGroupHealth representing the input proto object
	**/
	public static AccountGroupHealth fromProto(ApiProto.AccountGroupHealth proto) {
		AccountGroupHealth out = null;
		if (proto != null) {
			AccountGroupHealth.Builder outBuilder = AccountGroupHealth.newBuilder()
			.setRating(proto.getRating())
			.setReason(proto.getReason())
			.setUpdatedBy(proto.getUpdatedBy())
			.setUpdatedOn(proto.hasUpdatedOn()?new Date(proto.getUpdatedOn().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 AccountGroupHealth instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(ApiProto.AccountGroupHealth proto : protos) {
			out.add(AccountGroupHealth.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of ApiProto.AccountGroupHealth which is a proto object ready for wire transmission
	 **/
	 public ApiProto.AccountGroupHealth toProto() {
		 AccountGroupHealth obj = this;
		 ApiProto.AccountGroupHealth.Builder outBuilder = ApiProto.AccountGroupHealth.newBuilder();
		 outBuilder.setRating(obj.getRating());
		 outBuilder.setReason(obj.getReason());
		 outBuilder.setUpdatedBy(obj.getUpdatedBy());
		 if(obj.getUpdatedOn()!=null){outBuilder.setUpdatedOn(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getUpdatedOn().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.AccountGroupHealth instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (AccountGroupHealth obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy