com.rosetta.jptlegalagreement.model.CollateralRounding Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.CollateralRounding;
import com.rosetta.jptlegalagreement.model.CollateralRounding.CollateralRoundingBuilder;
import com.rosetta.jptlegalagreement.model.CollateralRounding.CollateralRoundingBuilderImpl;
import com.rosetta.jptlegalagreement.model.CollateralRounding.CollateralRoundingImpl;
import com.rosetta.jptlegalagreement.model.meta.CollateralRoundingMeta;
import com.rosetta.model.lib.RosettaModelObject;
import com.rosetta.model.lib.RosettaModelObjectBuilder;
import com.rosetta.model.lib.annotations.RosettaAttribute;
import com.rosetta.model.lib.annotations.RosettaDataType;
import com.rosetta.model.lib.meta.RosettaMetaData;
import com.rosetta.model.lib.path.RosettaPath;
import com.rosetta.model.lib.process.BuilderMerger;
import com.rosetta.model.lib.process.BuilderProcessor;
import com.rosetta.model.lib.process.Processor;
import java.math.BigDecimal;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="CollateralRounding", builder=CollateralRounding.CollateralRoundingBuilderImpl.class, version="test")
public interface CollateralRounding extends RosettaModelObject {
CollateralRoundingMeta metaData = new CollateralRoundingMeta();
/*********************** Getter Methods ***********************/
BigDecimal getDeliveryAmount();
BigDecimal getReturnAmount();
/*********************** Build Methods ***********************/
CollateralRounding build();
CollateralRounding.CollateralRoundingBuilder toBuilder();
static CollateralRounding.CollateralRoundingBuilder builder() {
return new CollateralRounding.CollateralRoundingBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends CollateralRounding> metaData() {
return metaData;
}
@Override
default Class extends CollateralRounding> getType() {
return CollateralRounding.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("deliveryAmount"), BigDecimal.class, getDeliveryAmount(), this);
processor.processBasic(path.newSubPath("returnAmount"), BigDecimal.class, getReturnAmount(), this);
}
/*********************** Builder Interface ***********************/
interface CollateralRoundingBuilder extends CollateralRounding, RosettaModelObjectBuilder {
CollateralRounding.CollateralRoundingBuilder setDeliveryAmount(BigDecimal deliveryAmount);
CollateralRounding.CollateralRoundingBuilder setReturnAmount(BigDecimal returnAmount);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("deliveryAmount"), BigDecimal.class, getDeliveryAmount(), this);
processor.processBasic(path.newSubPath("returnAmount"), BigDecimal.class, getReturnAmount(), this);
}
CollateralRounding.CollateralRoundingBuilder prune();
}
/*********************** Immutable Implementation of CollateralRounding ***********************/
class CollateralRoundingImpl implements CollateralRounding {
private final BigDecimal deliveryAmount;
private final BigDecimal returnAmount;
protected CollateralRoundingImpl(CollateralRounding.CollateralRoundingBuilder builder) {
this.deliveryAmount = builder.getDeliveryAmount();
this.returnAmount = builder.getReturnAmount();
}
@Override
@RosettaAttribute("deliveryAmount")
public BigDecimal getDeliveryAmount() {
return deliveryAmount;
}
@Override
@RosettaAttribute("returnAmount")
public BigDecimal getReturnAmount() {
return returnAmount;
}
@Override
public CollateralRounding build() {
return this;
}
@Override
public CollateralRounding.CollateralRoundingBuilder toBuilder() {
CollateralRounding.CollateralRoundingBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(CollateralRounding.CollateralRoundingBuilder builder) {
ofNullable(getDeliveryAmount()).ifPresent(builder::setDeliveryAmount);
ofNullable(getReturnAmount()).ifPresent(builder::setReturnAmount);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
CollateralRounding _that = getType().cast(o);
if (!Objects.equals(deliveryAmount, _that.getDeliveryAmount())) return false;
if (!Objects.equals(returnAmount, _that.getReturnAmount())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (deliveryAmount != null ? deliveryAmount.hashCode() : 0);
_result = 31 * _result + (returnAmount != null ? returnAmount.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CollateralRounding {" +
"deliveryAmount=" + this.deliveryAmount + ", " +
"returnAmount=" + this.returnAmount +
'}';
}
}
/*********************** Builder Implementation of CollateralRounding ***********************/
class CollateralRoundingBuilderImpl implements CollateralRounding.CollateralRoundingBuilder {
protected BigDecimal deliveryAmount;
protected BigDecimal returnAmount;
public CollateralRoundingBuilderImpl() {
}
@Override
@RosettaAttribute("deliveryAmount")
public BigDecimal getDeliveryAmount() {
return deliveryAmount;
}
@Override
@RosettaAttribute("returnAmount")
public BigDecimal getReturnAmount() {
return returnAmount;
}
@Override
@RosettaAttribute("deliveryAmount")
public CollateralRounding.CollateralRoundingBuilder setDeliveryAmount(BigDecimal deliveryAmount) {
this.deliveryAmount = deliveryAmount==null?null:deliveryAmount;
return this;
}
@Override
@RosettaAttribute("returnAmount")
public CollateralRounding.CollateralRoundingBuilder setReturnAmount(BigDecimal returnAmount) {
this.returnAmount = returnAmount==null?null:returnAmount;
return this;
}
@Override
public CollateralRounding build() {
return new CollateralRounding.CollateralRoundingImpl(this);
}
@Override
public CollateralRounding.CollateralRoundingBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public CollateralRounding.CollateralRoundingBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getDeliveryAmount()!=null) return true;
if (getReturnAmount()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public CollateralRounding.CollateralRoundingBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
CollateralRounding.CollateralRoundingBuilder o = (CollateralRounding.CollateralRoundingBuilder) other;
merger.mergeBasic(getDeliveryAmount(), o.getDeliveryAmount(), this::setDeliveryAmount);
merger.mergeBasic(getReturnAmount(), o.getReturnAmount(), this::setReturnAmount);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
CollateralRounding _that = getType().cast(o);
if (!Objects.equals(deliveryAmount, _that.getDeliveryAmount())) return false;
if (!Objects.equals(returnAmount, _that.getReturnAmount())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (deliveryAmount != null ? deliveryAmount.hashCode() : 0);
_result = 31 * _result + (returnAmount != null ? returnAmount.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CollateralRoundingBuilder {" +
"deliveryAmount=" + this.deliveryAmount + ", " +
"returnAmount=" + this.returnAmount +
'}';
}
}
}