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

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




	private final boolean suspended;
	private final boolean hasAlert;
	

	private Status (
		final boolean suspended,
		final boolean hasAlert)
		
	{
		this.suspended = suspended;
		this.hasAlert = hasAlert;
		
	}
	
	/**
	 * 
      * @return The final value of suspended on the object
	 **/
	public boolean getSuspended() {
		return this.suspended;
	}
	
	/**
	 * 
      * @return The final value of hasAlert on the object
	 **/
	public boolean getHasAlert() {
		return this.hasAlert;
	}
	

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy