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