com.rosetta.jptelections.model.TopE Maven / Gradle / Ivy
package com.rosetta.jptelections.model;
import com.rosetta.jptelections.model.SomeElectionWrapper;
import com.rosetta.jptelections.model.TopE;
import com.rosetta.jptelections.model.TopE.TopEBuilder;
import com.rosetta.jptelections.model.TopE.TopEBuilderImpl;
import com.rosetta.jptelections.model.TopE.TopEImpl;
import com.rosetta.jptelections.model.meta.TopEMeta;
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="TopE", builder=TopE.TopEBuilderImpl.class, version="test")
public interface TopE extends RosettaModelObject {
TopEMeta metaData = new TopEMeta();
/*********************** Getter Methods ***********************/
SomeElectionWrapper getElection();
/*********************** Build Methods ***********************/
TopE build();
TopE.TopEBuilder toBuilder();
static TopE.TopEBuilder builder() {
return new TopE.TopEBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends TopE> metaData() {
return metaData;
}
@Override
default Class extends TopE> getType() {
return TopE.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("election"), processor, SomeElectionWrapper.class, getElection());
}
/*********************** Builder Interface ***********************/
interface TopEBuilder extends TopE, RosettaModelObjectBuilder {
SomeElectionWrapper.SomeElectionWrapperBuilder getOrCreateElection();
SomeElectionWrapper.SomeElectionWrapperBuilder getElection();
TopE.TopEBuilder setElection(SomeElectionWrapper election);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("election"), processor, SomeElectionWrapper.SomeElectionWrapperBuilder.class, getElection());
}
TopE.TopEBuilder prune();
}
/*********************** Immutable Implementation of TopE ***********************/
class TopEImpl implements TopE {
private final SomeElectionWrapper election;
protected TopEImpl(TopE.TopEBuilder builder) {
this.election = ofNullable(builder.getElection()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("election")
public SomeElectionWrapper getElection() {
return election;
}
@Override
public TopE build() {
return this;
}
@Override
public TopE.TopEBuilder toBuilder() {
TopE.TopEBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(TopE.TopEBuilder builder) {
ofNullable(getElection()).ifPresent(builder::setElection);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
TopE _that = getType().cast(o);
if (!Objects.equals(election, _that.getElection())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (election != null ? election.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TopE {" +
"election=" + this.election +
'}';
}
}
/*********************** Builder Implementation of TopE ***********************/
class TopEBuilderImpl implements TopE.TopEBuilder {
protected SomeElectionWrapper.SomeElectionWrapperBuilder election;
public TopEBuilderImpl() {
}
@Override
@RosettaAttribute("election")
public SomeElectionWrapper.SomeElectionWrapperBuilder getElection() {
return election;
}
@Override
public SomeElectionWrapper.SomeElectionWrapperBuilder getOrCreateElection() {
SomeElectionWrapper.SomeElectionWrapperBuilder result;
if (election!=null) {
result = election;
}
else {
result = election = SomeElectionWrapper.builder();
}
return result;
}
@Override
@RosettaAttribute("election")
public TopE.TopEBuilder setElection(SomeElectionWrapper election) {
this.election = election==null?null:election.toBuilder();
return this;
}
@Override
public TopE build() {
return new TopE.TopEImpl(this);
}
@Override
public TopE.TopEBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public TopE.TopEBuilder prune() {
if (election!=null && !election.prune().hasData()) election = null;
return this;
}
@Override
public boolean hasData() {
if (getElection()!=null && getElection().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public TopE.TopEBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
TopE.TopEBuilder o = (TopE.TopEBuilder) other;
merger.mergeRosetta(getElection(), o.getElection(), this::setElection);
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;
TopE _that = getType().cast(o);
if (!Objects.equals(election, _that.getElection())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (election != null ? election.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TopEBuilder {" +
"election=" + this.election +
'}';
}
}
}