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