
com.vendasta.sales.v1.internal.RevenueComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sales.v1 Show documentation
Show all versions of sales.v1 Show documentation
Java SDK for service sales
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.WorkflowProto;
/**
*
**/
public final class RevenueComponent {
private final long value;
private final RevenuePeriod period;
private final boolean isStartingRevenue;
private RevenueComponent (
final long value,
final RevenuePeriod period,
final boolean isStartingRevenue)
{
this.value = value;
this.period = period;
this.isStartingRevenue = isStartingRevenue;
}
/**
* The value in the smallest common currency unit i.e. cents. Therefore 4000 would represent $40.00.
* @return The final value of value on the object
**/
public long getValue() {
return this.value;
}
/**
* The frequency this revenue occurs.
* @return The final value of period on the object
**/
public RevenuePeriod getPeriod() {
return this.period;
}
/**
* The indication if this is only the starting price or the actual price
* @return The final value of isStartingRevenue on the object
**/
public boolean getIsStartingRevenue() {
return this.isStartingRevenue;
}
public static class Builder {
private long value;
private RevenuePeriod period;
private boolean isStartingRevenue;
public Builder() {
this.value = 0;
this.period = null;
this.isStartingRevenue = false;
}
/**
* Adds a value to the builder for value
* @param value Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setValue(long value) {
this.value = value;
return this;
}
/**
* Adds a value to the builder for period
* @param period Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setPeriod(RevenuePeriod period) {
this.period = period;
return this;
}
/**
* Adds a value to the builder for isStartingRevenue
* @param isStartingRevenue Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setIsStartingRevenue(boolean isStartingRevenue) {
this.isStartingRevenue = isStartingRevenue;
return this;
}
/**
* Takes the configuration in the mutable Builder and uses it to instantiate a final instance
* of the RevenueComponent class
* @return The instantiated final RevenueComponent
**/
public RevenueComponent build() {
return new RevenueComponent(
this.value,
this.period,
this.isStartingRevenue);
}
}
/**
* Returns a Builder for RevenueComponent, which is a mutable representation of the object. Once the
* client has built up an object they can then create an immutable RevenueComponent 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 RevenueComponent instance
**/
public String toString() {
String result = "RevenueComponent\n";
result += "-> value: (long)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.value).split("\n"))) + "\n";
result += "-> period: (RevenuePeriod)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.period).split("\n"))) + "\n";
result += "-> isStartingRevenue: (boolean)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.isStartingRevenue).split("\n"))) + "\n";
return result;
}
/**
* Allows for simple conversion between the low-level generated protobuf object to
* RevenueComponent, which is much more usable.
* @return An instance of RevenueComponent representing the input proto object
**/
public static RevenueComponent fromProto(WorkflowProto.RevenueComponent proto) {
RevenueComponent out = null;
if (proto != null) {
RevenueComponent.Builder outBuilder = RevenueComponent.newBuilder()
.setValue(proto.getValue())
.setPeriod(RevenuePeriod.fromProto(proto.getPeriod()))
.setIsStartingRevenue(proto.getIsStartingRevenue());
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 RevenueComponent instances representing the input proto objects
**/
public static List fromProtos(List protos) {
List out = new ArrayList();
for(WorkflowProto.RevenueComponent proto : protos) {
out.add(RevenueComponent.fromProto(proto));
}
return out;
}
/**
* Allows for simple conversion of an object to the low-level generated protobuf object.
* @return An instance of WorkflowProto.RevenueComponent which is a proto object ready for wire transmission
**/
public WorkflowProto.RevenueComponent toProto() {
RevenueComponent obj = this;
WorkflowProto.RevenueComponent.Builder outBuilder = WorkflowProto.RevenueComponent.newBuilder();
outBuilder.setValue(obj.getValue());
outBuilder.setPeriod(obj.getPeriod() != null?obj.getPeriod().toProto():null);
outBuilder.setIsStartingRevenue(obj.getIsStartingRevenue());
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 WorkflowProto.RevenueComponent instances representing the input objects.
*/
public static List toProtos(List objects) {
List out = new ArrayList();
if(objects != null) {
for (RevenueComponent obj : objects) {
out.add(obj!=null?obj.toProto():null);
}
}
return out;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy