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