com.rosetta.jptlegalagreement.model.EligibleCollateral Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.CollateralAssetDefinitionsEnum;
import com.rosetta.jptlegalagreement.model.EligibleCollateral;
import com.rosetta.jptlegalagreement.model.EligibleCollateral.EligibleCollateralBuilder;
import com.rosetta.jptlegalagreement.model.EligibleCollateral.EligibleCollateralBuilderImpl;
import com.rosetta.jptlegalagreement.model.EligibleCollateral.EligibleCollateralImpl;
import com.rosetta.jptlegalagreement.model.meta.EligibleCollateralMeta;
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="EligibleCollateral", builder=EligibleCollateral.EligibleCollateralBuilderImpl.class, version="test")
public interface EligibleCollateral extends RosettaModelObject {
EligibleCollateralMeta metaData = new EligibleCollateralMeta();
/*********************** Getter Methods ***********************/
CollateralAssetDefinitionsEnum getEligibleAsset();
BigDecimal getValuationPercentage();
/*********************** Build Methods ***********************/
EligibleCollateral build();
EligibleCollateral.EligibleCollateralBuilder toBuilder();
static EligibleCollateral.EligibleCollateralBuilder builder() {
return new EligibleCollateral.EligibleCollateralBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends EligibleCollateral> metaData() {
return metaData;
}
@Override
default Class extends EligibleCollateral> getType() {
return EligibleCollateral.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("eligibleAsset"), CollateralAssetDefinitionsEnum.class, getEligibleAsset(), this);
processor.processBasic(path.newSubPath("valuationPercentage"), BigDecimal.class, getValuationPercentage(), this);
}
/*********************** Builder Interface ***********************/
interface EligibleCollateralBuilder extends EligibleCollateral, RosettaModelObjectBuilder {
EligibleCollateral.EligibleCollateralBuilder setEligibleAsset(CollateralAssetDefinitionsEnum eligibleAsset);
EligibleCollateral.EligibleCollateralBuilder setValuationPercentage(BigDecimal valuationPercentage);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("eligibleAsset"), CollateralAssetDefinitionsEnum.class, getEligibleAsset(), this);
processor.processBasic(path.newSubPath("valuationPercentage"), BigDecimal.class, getValuationPercentage(), this);
}
EligibleCollateral.EligibleCollateralBuilder prune();
}
/*********************** Immutable Implementation of EligibleCollateral ***********************/
class EligibleCollateralImpl implements EligibleCollateral {
private final CollateralAssetDefinitionsEnum eligibleAsset;
private final BigDecimal valuationPercentage;
protected EligibleCollateralImpl(EligibleCollateral.EligibleCollateralBuilder builder) {
this.eligibleAsset = builder.getEligibleAsset();
this.valuationPercentage = builder.getValuationPercentage();
}
@Override
@RosettaAttribute("eligibleAsset")
public CollateralAssetDefinitionsEnum getEligibleAsset() {
return eligibleAsset;
}
@Override
@RosettaAttribute("valuationPercentage")
public BigDecimal getValuationPercentage() {
return valuationPercentage;
}
@Override
public EligibleCollateral build() {
return this;
}
@Override
public EligibleCollateral.EligibleCollateralBuilder toBuilder() {
EligibleCollateral.EligibleCollateralBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(EligibleCollateral.EligibleCollateralBuilder builder) {
ofNullable(getEligibleAsset()).ifPresent(builder::setEligibleAsset);
ofNullable(getValuationPercentage()).ifPresent(builder::setValuationPercentage);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
EligibleCollateral _that = getType().cast(o);
if (!Objects.equals(eligibleAsset, _that.getEligibleAsset())) return false;
if (!Objects.equals(valuationPercentage, _that.getValuationPercentage())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (eligibleAsset != null ? eligibleAsset.getClass().getName().hashCode() : 0);
_result = 31 * _result + (valuationPercentage != null ? valuationPercentage.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "EligibleCollateral {" +
"eligibleAsset=" + this.eligibleAsset + ", " +
"valuationPercentage=" + this.valuationPercentage +
'}';
}
}
/*********************** Builder Implementation of EligibleCollateral ***********************/
class EligibleCollateralBuilderImpl implements EligibleCollateral.EligibleCollateralBuilder {
protected CollateralAssetDefinitionsEnum eligibleAsset;
protected BigDecimal valuationPercentage;
public EligibleCollateralBuilderImpl() {
}
@Override
@RosettaAttribute("eligibleAsset")
public CollateralAssetDefinitionsEnum getEligibleAsset() {
return eligibleAsset;
}
@Override
@RosettaAttribute("valuationPercentage")
public BigDecimal getValuationPercentage() {
return valuationPercentage;
}
@Override
@RosettaAttribute("eligibleAsset")
public EligibleCollateral.EligibleCollateralBuilder setEligibleAsset(CollateralAssetDefinitionsEnum eligibleAsset) {
this.eligibleAsset = eligibleAsset==null?null:eligibleAsset;
return this;
}
@Override
@RosettaAttribute("valuationPercentage")
public EligibleCollateral.EligibleCollateralBuilder setValuationPercentage(BigDecimal valuationPercentage) {
this.valuationPercentage = valuationPercentage==null?null:valuationPercentage;
return this;
}
@Override
public EligibleCollateral build() {
return new EligibleCollateral.EligibleCollateralImpl(this);
}
@Override
public EligibleCollateral.EligibleCollateralBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public EligibleCollateral.EligibleCollateralBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getEligibleAsset()!=null) return true;
if (getValuationPercentage()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public EligibleCollateral.EligibleCollateralBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
EligibleCollateral.EligibleCollateralBuilder o = (EligibleCollateral.EligibleCollateralBuilder) other;
merger.mergeBasic(getEligibleAsset(), o.getEligibleAsset(), this::setEligibleAsset);
merger.mergeBasic(getValuationPercentage(), o.getValuationPercentage(), this::setValuationPercentage);
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;
EligibleCollateral _that = getType().cast(o);
if (!Objects.equals(eligibleAsset, _that.getEligibleAsset())) return false;
if (!Objects.equals(valuationPercentage, _that.getValuationPercentage())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (eligibleAsset != null ? eligibleAsset.getClass().getName().hashCode() : 0);
_result = 31 * _result + (valuationPercentage != null ? valuationPercentage.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "EligibleCollateralBuilder {" +
"eligibleAsset=" + this.eligibleAsset + ", " +
"valuationPercentage=" + this.valuationPercentage +
'}';
}
}
}