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

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

/**
 * 
 **/
public final class AddressValidationResult {




	private final String businessId;
	private final String businessName;
	private final AddressInfo currentAddress;
	private final List suggestedAddresses;
	private final List addressErrors;
	

	private AddressValidationResult (
		final String businessId,
		final String businessName,
		final AddressInfo currentAddress,
		final List suggestedAddresses,
		final List addressErrors)
		
	{
		this.businessId = businessId;
		this.businessName = businessName;
		this.currentAddress = currentAddress;
		this.suggestedAddresses = suggestedAddresses;
		this.addressErrors = addressErrors;
		
	}
	
	/**
	 * The id of the business
      * @return The final value of businessId on the object
	 **/
	public String getBusinessId() {
		return this.businessId;
	}
	
	/**
	 * The name of the business
      * @return The final value of businessName on the object
	 **/
	public String getBusinessName() {
		return this.businessName;
	}
	
	/**
	 * The business's current address info
      * @return The final value of currentAddress on the object
	 **/
	public AddressInfo getCurrentAddress() {
		return this.currentAddress;
	}
	
	/**
	 * List of SmartyStreets suggested valid addresses
      * @return The final value of suggestedAddresses on the object
	 **/
	public List getSuggestedAddresses() {
		return this.suggestedAddresses;
	}
	
	/**
	 * Problems with the current address in human readable format
      * @return The final value of addressErrors on the object
	 **/
	public List getAddressErrors() {
		return this.addressErrors;
	}
	

	public static class Builder {
		private String businessId;
		private String businessName;
		private AddressInfo currentAddress;
		private List suggestedAddresses;
		private List addressErrors;
		
		public Builder() {
			this.businessId = "";
			this.businessName = "";
			this.currentAddress = null;
			this.suggestedAddresses = null;
			this.addressErrors = new ArrayList();
			
		}
		
		/**
		  * Adds a value to the builder for businessId
		  * @param businessId Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setBusinessId(String businessId) {
			this.businessId = businessId;
			return this;
		}
		
		/**
		  * Adds a value to the builder for businessName
		  * @param businessName Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setBusinessName(String businessName) {
			this.businessName = businessName;
			return this;
		}
		
		/**
		  * Adds a value to the builder for currentAddress
		  * @param currentAddress Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setCurrentAddress(AddressInfo currentAddress) {
			this.currentAddress = currentAddress;
			return this;
		}
		
		/**
		  * Adds a value to the builder for suggestedAddresses
		  * @param suggestedAddresses Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setSuggestedAddresses(List suggestedAddresses) {
			this.suggestedAddresses = suggestedAddresses;
			return this;
		}
		
		/**
		  * Adds a value to the builder for addressErrors
		  * @param addressErrors Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setAddressErrors(List addressErrors) {
			this.addressErrors = addressErrors;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the AddressValidationResult class
		  * @return The instantiated final AddressValidationResult
		 **/
		public AddressValidationResult build() {
			return new AddressValidationResult(
				this.businessId,
				this.businessName,
				this.currentAddress,
				this.suggestedAddresses,
				this.addressErrors);
		}
	}

	/**
	 * Returns a Builder for AddressValidationResult, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable AddressValidationResult 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 AddressValidationResult instance
	 **/
	 public String toString() {
		 String result = "AddressValidationResult\n";
		 result += "-> businessId: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.businessId).split("\n"))) + "\n"; 
		 result += "-> businessName: (String)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.businessName).split("\n"))) + "\n"; 
		 result += "-> currentAddress: (AddressInfo)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.currentAddress).split("\n"))) + "\n"; 
		 result += "-> suggestedAddresses: (List)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.suggestedAddresses).split("\n"))) + "\n"; 
		 result += "-> addressErrors: (List)"
		     + StringUtils.join("\n  ", Arrays.asList(String.valueOf(this.addressErrors).split("\n"))) + "\n"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* AddressValidationResult, which is much more usable.
	* @return An instance of AddressValidationResult representing the input proto object
	**/
	public static AddressValidationResult fromProto(AccountValidationProto.AddressValidationResult proto) {
		AddressValidationResult out = null;
		if (proto != null) {
			AddressValidationResult.Builder outBuilder = AddressValidationResult.newBuilder()
			.setBusinessId(proto.getBusinessId())
			.setBusinessName(proto.getBusinessName())
			.setCurrentAddress(AddressInfo.fromProto(proto.getCurrentAddress()))
			.setSuggestedAddresses(AddressInfo.fromProtos(proto.getSuggestedAddressesList()))
			.setAddressErrors(proto.getAddressErrorsList());
			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 AddressValidationResult instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(AccountValidationProto.AddressValidationResult proto : protos) {
			out.add(AddressValidationResult.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of AccountValidationProto.AddressValidationResult which is a proto object ready for wire transmission
	 **/
	 public AccountValidationProto.AddressValidationResult toProto() {
		 AddressValidationResult obj = this;
		 AccountValidationProto.AddressValidationResult.Builder outBuilder = AccountValidationProto.AddressValidationResult.newBuilder();
		 outBuilder.setBusinessId(obj.getBusinessId());
		 outBuilder.setBusinessName(obj.getBusinessName());
		 if(obj.getCurrentAddress() != null){outBuilder.setCurrentAddress(obj.getCurrentAddress().toProto());}
		 outBuilder.addAllSuggestedAddresses(AddressInfo.toProtos(obj.getSuggestedAddresses()));
		 outBuilder.addAllAddressErrors(obj.getAddressErrors());
		 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 AccountValidationProto.AddressValidationResult instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (AddressValidationResult obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy