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

com.vendasta.sales.v1.internal.BusinessSearchResponse Maven / Gradle / Ivy

The newest version!
package com.vendasta.sales.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.sales.v1.generated.ApiProto;

/**
 * 
 **/
public final class BusinessSearchResponse {




	private final List businesses;
	private final BusinessPagedResponseMetadata pagingMetadata;
	

	private BusinessSearchResponse (
		final List businesses,
		final BusinessPagedResponseMetadata pagingMetadata)
		
	{
		this.businesses = businesses;
		this.pagingMetadata = pagingMetadata;
		
	}
	
	/**
	 * 
      * @return The final value of businesses on the object
	 **/
	public List getBusinesses() {
		return this.businesses;
	}
	
	/**
	 * 
      * @return The final value of pagingMetadata on the object
	 **/
	public BusinessPagedResponseMetadata getPagingMetadata() {
		return this.pagingMetadata;
	}
	

	public static class Builder {
		private List businesses;
		private BusinessPagedResponseMetadata pagingMetadata;
		
		public Builder() {
			this.businesses = null;
			this.pagingMetadata = null;
			
		}
		
		/**
		  * Adds a value to the builder for businesses
		  * @param businesses Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setBusinesses(List businesses) {
			this.businesses = businesses;
			return this;
		}
		
		/**
		  * Adds a value to the builder for pagingMetadata
		  * @param pagingMetadata Value to assign to the mutable Builder
		  * @return The Builder instance so that call chaining works
		 **/
		public Builder setPagingMetadata(BusinessPagedResponseMetadata pagingMetadata) {
			this.pagingMetadata = pagingMetadata;
			return this;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the BusinessSearchResponse class
		  * @return The instantiated final BusinessSearchResponse
		 **/
		public BusinessSearchResponse build() {
			return new BusinessSearchResponse(
				this.businesses,
				this.pagingMetadata);
		}
	}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy