com.rosetta.jptlegalagreement.model.Regime Maven / Gradle / Ivy
The newest version!
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.Regime;
import com.rosetta.jptlegalagreement.model.Regime.RegimeBuilder;
import com.rosetta.jptlegalagreement.model.Regime.RegimeBuilderImpl;
import com.rosetta.jptlegalagreement.model.Regime.RegimeImpl;
import com.rosetta.jptlegalagreement.model.RegimeElection;
import com.rosetta.jptlegalagreement.model.RegimeElection.RegimeElectionBuilder;
import com.rosetta.jptlegalagreement.model.meta.RegimeMeta;
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="Regime", builder=Regime.RegimeBuilderImpl.class, version="test")
public interface Regime extends RosettaModelObject {
RegimeMeta metaData = new RegimeMeta();
/*********************** Getter Methods ***********************/
RegimeElection getPartyElection();
/*********************** Build Methods ***********************/
Regime build();
Regime.RegimeBuilder toBuilder();
static Regime.RegimeBuilder builder() {
return new Regime.RegimeBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Regime> metaData() {
return metaData;
}
@Override
default Class extends Regime> getType() {
return Regime.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("partyElection"), processor, RegimeElection.class, getPartyElection());
}
/*********************** Builder Interface ***********************/
interface RegimeBuilder extends Regime, RosettaModelObjectBuilder {
RegimeElection.RegimeElectionBuilder getOrCreatePartyElection();
@Override
RegimeElection.RegimeElectionBuilder getPartyElection();
Regime.RegimeBuilder setPartyElection(RegimeElection partyElection);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("partyElection"), processor, RegimeElection.RegimeElectionBuilder.class, getPartyElection());
}
Regime.RegimeBuilder prune();
}
/*********************** Immutable Implementation of Regime ***********************/
class RegimeImpl implements Regime {
private final RegimeElection partyElection;
protected RegimeImpl(Regime.RegimeBuilder builder) {
this.partyElection = ofNullable(builder.getPartyElection()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("partyElection")
public RegimeElection getPartyElection() {
return partyElection;
}
@Override
public Regime build() {
return this;
}
@Override
public Regime.RegimeBuilder toBuilder() {
Regime.RegimeBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Regime.RegimeBuilder 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;
Regime _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 "Regime {" +
"partyElection=" + this.partyElection +
'}';
}
}
/*********************** Builder Implementation of Regime ***********************/
class RegimeBuilderImpl implements Regime.RegimeBuilder {
protected RegimeElection.RegimeElectionBuilder partyElection;
@Override
@RosettaAttribute("partyElection")
public RegimeElection.RegimeElectionBuilder getPartyElection() {
return partyElection;
}
@Override
public RegimeElection.RegimeElectionBuilder getOrCreatePartyElection() {
RegimeElection.RegimeElectionBuilder result;
if (partyElection!=null) {
result = partyElection;
}
else {
result = partyElection = RegimeElection.builder();
}
return result;
}
@Override
@RosettaAttribute("partyElection")
public Regime.RegimeBuilder setPartyElection(RegimeElection _partyElection) {
this.partyElection = _partyElection == null ? null : _partyElection.toBuilder();
return this;
}
@Override
public Regime build() {
return new Regime.RegimeImpl(this);
}
@Override
public Regime.RegimeBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Regime.RegimeBuilder 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 Regime.RegimeBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Regime.RegimeBuilder o = (Regime.RegimeBuilder) 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;
Regime _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 "RegimeBuilder {" +
"partyElection=" + this.partyElection +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy