com.rosetta.jptlegalagreement.model.MinimumTransferAmount Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.ElectiveAmountElection;
import com.rosetta.jptlegalagreement.model.MinimumTransferAmount;
import com.rosetta.jptlegalagreement.model.MinimumTransferAmount.MinimumTransferAmountBuilder;
import com.rosetta.jptlegalagreement.model.MinimumTransferAmount.MinimumTransferAmountBuilderImpl;
import com.rosetta.jptlegalagreement.model.MinimumTransferAmount.MinimumTransferAmountImpl;
import com.rosetta.jptlegalagreement.model.meta.MinimumTransferAmountMeta;
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.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="MinimumTransferAmount", builder=MinimumTransferAmount.MinimumTransferAmountBuilderImpl.class, version="test")
public interface MinimumTransferAmount extends RosettaModelObject {
MinimumTransferAmountMeta metaData = new MinimumTransferAmountMeta();
/*********************** Getter Methods ***********************/
ElectiveAmountElection getPartyElection();
/*********************** Build Methods ***********************/
MinimumTransferAmount build();
MinimumTransferAmount.MinimumTransferAmountBuilder toBuilder();
static MinimumTransferAmount.MinimumTransferAmountBuilder builder() {
return new MinimumTransferAmount.MinimumTransferAmountBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends MinimumTransferAmount> metaData() {
return metaData;
}
@Override
default Class extends MinimumTransferAmount> getType() {
return MinimumTransferAmount.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("partyElection"), processor, ElectiveAmountElection.class, getPartyElection());
}
/*********************** Builder Interface ***********************/
interface MinimumTransferAmountBuilder extends MinimumTransferAmount, RosettaModelObjectBuilder {
ElectiveAmountElection.ElectiveAmountElectionBuilder getOrCreatePartyElection();
ElectiveAmountElection.ElectiveAmountElectionBuilder getPartyElection();
MinimumTransferAmount.MinimumTransferAmountBuilder setPartyElection(ElectiveAmountElection partyElection);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("partyElection"), processor, ElectiveAmountElection.ElectiveAmountElectionBuilder.class, getPartyElection());
}
MinimumTransferAmount.MinimumTransferAmountBuilder prune();
}
/*********************** Immutable Implementation of MinimumTransferAmount ***********************/
class MinimumTransferAmountImpl implements MinimumTransferAmount {
private final ElectiveAmountElection partyElection;
protected MinimumTransferAmountImpl(MinimumTransferAmount.MinimumTransferAmountBuilder builder) {
this.partyElection = ofNullable(builder.getPartyElection()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("partyElection")
public ElectiveAmountElection getPartyElection() {
return partyElection;
}
@Override
public MinimumTransferAmount build() {
return this;
}
@Override
public MinimumTransferAmount.MinimumTransferAmountBuilder toBuilder() {
MinimumTransferAmount.MinimumTransferAmountBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(MinimumTransferAmount.MinimumTransferAmountBuilder builder) {
ofNullable(getPartyElection()).ifPresent(builder::setPartyElection);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
MinimumTransferAmount _that = getType().cast(o);
if (!Objects.equals(partyElection, _that.getPartyElection())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "MinimumTransferAmount {" +
"partyElection=" + this.partyElection +
'}';
}
}
/*********************** Builder Implementation of MinimumTransferAmount ***********************/
class MinimumTransferAmountBuilderImpl implements MinimumTransferAmount.MinimumTransferAmountBuilder {
protected ElectiveAmountElection.ElectiveAmountElectionBuilder partyElection;
public MinimumTransferAmountBuilderImpl() {
}
@Override
@RosettaAttribute("partyElection")
public ElectiveAmountElection.ElectiveAmountElectionBuilder getPartyElection() {
return partyElection;
}
@Override
public ElectiveAmountElection.ElectiveAmountElectionBuilder getOrCreatePartyElection() {
ElectiveAmountElection.ElectiveAmountElectionBuilder result;
if (partyElection!=null) {
result = partyElection;
}
else {
result = partyElection = ElectiveAmountElection.builder();
}
return result;
}
@Override
@RosettaAttribute("partyElection")
public MinimumTransferAmount.MinimumTransferAmountBuilder setPartyElection(ElectiveAmountElection partyElection) {
this.partyElection = partyElection==null?null:partyElection.toBuilder();
return this;
}
@Override
public MinimumTransferAmount build() {
return new MinimumTransferAmount.MinimumTransferAmountImpl(this);
}
@Override
public MinimumTransferAmount.MinimumTransferAmountBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public MinimumTransferAmount.MinimumTransferAmountBuilder prune() {
if (partyElection!=null && !partyElection.prune().hasData()) partyElection = null;
return this;
}
@Override
public boolean hasData() {
if (getPartyElection()!=null && getPartyElection().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public MinimumTransferAmount.MinimumTransferAmountBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
MinimumTransferAmount.MinimumTransferAmountBuilder o = (MinimumTransferAmount.MinimumTransferAmountBuilder) other;
merger.mergeRosetta(getPartyElection(), o.getPartyElection(), this::setPartyElection);
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;
MinimumTransferAmount _that = getType().cast(o);
if (!Objects.equals(partyElection, _that.getPartyElection())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "MinimumTransferAmountBuilder {" +
"partyElection=" + this.partyElection +
'}';
}
}
}