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