com.rosetta.jptlegalagreement.model.TerminationCurrencyElection Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.Party;
import com.rosetta.jptlegalagreement.model.TerminationCurrencyElection;
import com.rosetta.jptlegalagreement.model.TerminationCurrencyElection.TerminationCurrencyElectionBuilder;
import com.rosetta.jptlegalagreement.model.TerminationCurrencyElection.TerminationCurrencyElectionBuilderImpl;
import com.rosetta.jptlegalagreement.model.TerminationCurrencyElection.TerminationCurrencyElectionImpl;
import com.rosetta.jptlegalagreement.model.meta.TerminationCurrencyElectionMeta;
import com.rosetta.jptlegalagreement.model.metafields.ReferenceWithMetaParty;
import com.rosetta.jptlegalagreement.model.metafields.ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder;
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 com.rosetta.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="TerminationCurrencyElection", builder=TerminationCurrencyElection.TerminationCurrencyElectionBuilderImpl.class, version="test")
public interface TerminationCurrencyElection extends RosettaModelObject {
TerminationCurrencyElectionMeta metaData = new TerminationCurrencyElectionMeta();
/*********************** Getter Methods ***********************/
ReferenceWithMetaParty getParty();
FieldWithMetaString getCurrency();
/*********************** Build Methods ***********************/
TerminationCurrencyElection build();
TerminationCurrencyElection.TerminationCurrencyElectionBuilder toBuilder();
static TerminationCurrencyElection.TerminationCurrencyElectionBuilder builder() {
return new TerminationCurrencyElection.TerminationCurrencyElectionBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends TerminationCurrencyElection> metaData() {
return metaData;
}
@Override
default Class extends TerminationCurrencyElection> getType() {
return TerminationCurrencyElection.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("party"), processor, ReferenceWithMetaParty.class, getParty());
processRosetta(path.newSubPath("currency"), processor, FieldWithMetaString.class, getCurrency());
}
/*********************** Builder Interface ***********************/
interface TerminationCurrencyElectionBuilder extends TerminationCurrencyElection, RosettaModelObjectBuilder {
ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreateParty();
ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getParty();
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateCurrency();
FieldWithMetaString.FieldWithMetaStringBuilder getCurrency();
TerminationCurrencyElection.TerminationCurrencyElectionBuilder setParty(ReferenceWithMetaParty party0);
TerminationCurrencyElection.TerminationCurrencyElectionBuilder setPartyValue(Party party1);
TerminationCurrencyElection.TerminationCurrencyElectionBuilder setCurrency(FieldWithMetaString currency0);
TerminationCurrencyElection.TerminationCurrencyElectionBuilder setCurrencyValue(String currency1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("party"), processor, ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder.class, getParty());
processRosetta(path.newSubPath("currency"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getCurrency());
}
TerminationCurrencyElection.TerminationCurrencyElectionBuilder prune();
}
/*********************** Immutable Implementation of TerminationCurrencyElection ***********************/
class TerminationCurrencyElectionImpl implements TerminationCurrencyElection {
private final ReferenceWithMetaParty party;
private final FieldWithMetaString currency;
protected TerminationCurrencyElectionImpl(TerminationCurrencyElection.TerminationCurrencyElectionBuilder builder) {
this.party = ofNullable(builder.getParty()).map(f->f.build()).orElse(null);
this.currency = ofNullable(builder.getCurrency()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("party")
public ReferenceWithMetaParty getParty() {
return party;
}
@Override
@RosettaAttribute("currency")
public FieldWithMetaString getCurrency() {
return currency;
}
@Override
public TerminationCurrencyElection build() {
return this;
}
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder toBuilder() {
TerminationCurrencyElection.TerminationCurrencyElectionBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(TerminationCurrencyElection.TerminationCurrencyElectionBuilder builder) {
ofNullable(getParty()).ifPresent(builder::setParty);
ofNullable(getCurrency()).ifPresent(builder::setCurrency);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
TerminationCurrencyElection _that = getType().cast(o);
if (!Objects.equals(party, _that.getParty())) return false;
if (!Objects.equals(currency, _that.getCurrency())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (party != null ? party.hashCode() : 0);
_result = 31 * _result + (currency != null ? currency.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TerminationCurrencyElection {" +
"party=" + this.party + ", " +
"currency=" + this.currency +
'}';
}
}
/*********************** Builder Implementation of TerminationCurrencyElection ***********************/
class TerminationCurrencyElectionBuilderImpl implements TerminationCurrencyElection.TerminationCurrencyElectionBuilder {
protected ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder party;
protected FieldWithMetaString.FieldWithMetaStringBuilder currency;
public TerminationCurrencyElectionBuilderImpl() {
}
@Override
@RosettaAttribute("party")
public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getParty() {
return party;
}
@Override
public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreateParty() {
ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder result;
if (party!=null) {
result = party;
}
else {
result = party = ReferenceWithMetaParty.builder();
}
return result;
}
@Override
@RosettaAttribute("currency")
public FieldWithMetaString.FieldWithMetaStringBuilder getCurrency() {
return currency;
}
@Override
public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateCurrency() {
FieldWithMetaString.FieldWithMetaStringBuilder result;
if (currency!=null) {
result = currency;
}
else {
result = currency = FieldWithMetaString.builder();
}
return result;
}
@Override
@RosettaAttribute("party")
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder setParty(ReferenceWithMetaParty party) {
this.party = party==null?null:party.toBuilder();
return this;
}
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder setPartyValue(Party party) {
this.getOrCreateParty().setValue(party);
return this;
}
@Override
@RosettaAttribute("currency")
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder setCurrency(FieldWithMetaString currency) {
this.currency = currency==null?null:currency.toBuilder();
return this;
}
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder setCurrencyValue(String currency) {
this.getOrCreateCurrency().setValue(currency);
return this;
}
@Override
public TerminationCurrencyElection build() {
return new TerminationCurrencyElection.TerminationCurrencyElectionImpl(this);
}
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder prune() {
if (party!=null && !party.prune().hasData()) party = null;
if (currency!=null && !currency.prune().hasData()) currency = null;
return this;
}
@Override
public boolean hasData() {
if (getParty()!=null && getParty().hasData()) return true;
if (getCurrency()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public TerminationCurrencyElection.TerminationCurrencyElectionBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
TerminationCurrencyElection.TerminationCurrencyElectionBuilder o = (TerminationCurrencyElection.TerminationCurrencyElectionBuilder) other;
merger.mergeRosetta(getParty(), o.getParty(), this::setParty);
merger.mergeRosetta(getCurrency(), o.getCurrency(), this::setCurrency);
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;
TerminationCurrencyElection _that = getType().cast(o);
if (!Objects.equals(party, _that.getParty())) return false;
if (!Objects.equals(currency, _that.getCurrency())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (party != null ? party.hashCode() : 0);
_result = 31 * _result + (currency != null ? currency.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TerminationCurrencyElectionBuilder {" +
"party=" + this.party + ", " +
"currency=" + this.currency +
'}';
}
}
}