com.rosetta.testother.model.ContProd Maven / Gradle / Ivy
package com.rosetta.testother.model;
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 com.rosetta.testother.model.ContProd;
import com.rosetta.testother.model.ContProd.ContProdBuilder;
import com.rosetta.testother.model.ContProd.ContProdBuilderImpl;
import com.rosetta.testother.model.ContProd.ContProdImpl;
import com.rosetta.testother.model.EcTerms;
import com.rosetta.testother.model.ProdId;
import com.rosetta.testother.model.meta.ContProdMeta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="ContProd", builder=ContProd.ContProdBuilderImpl.class, version="test")
public interface ContProd extends RosettaModelObject {
ContProdMeta metaData = new ContProdMeta();
/*********************** Getter Methods ***********************/
EcTerms getEcTerms();
ProdId getProdId();
/*********************** Build Methods ***********************/
ContProd build();
ContProd.ContProdBuilder toBuilder();
static ContProd.ContProdBuilder builder() {
return new ContProd.ContProdBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ContProd> metaData() {
return metaData;
}
@Override
default Class extends ContProd> getType() {
return ContProd.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("ecTerms"), processor, EcTerms.class, getEcTerms());
processRosetta(path.newSubPath("prodId"), processor, ProdId.class, getProdId());
}
/*********************** Builder Interface ***********************/
interface ContProdBuilder extends ContProd, RosettaModelObjectBuilder {
EcTerms.EcTermsBuilder getOrCreateEcTerms();
EcTerms.EcTermsBuilder getEcTerms();
ProdId.ProdIdBuilder getOrCreateProdId();
ProdId.ProdIdBuilder getProdId();
ContProd.ContProdBuilder setEcTerms(EcTerms ecTerms);
ContProd.ContProdBuilder setProdId(ProdId prodId);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("ecTerms"), processor, EcTerms.EcTermsBuilder.class, getEcTerms());
processRosetta(path.newSubPath("prodId"), processor, ProdId.ProdIdBuilder.class, getProdId());
}
ContProd.ContProdBuilder prune();
}
/*********************** Immutable Implementation of ContProd ***********************/
class ContProdImpl implements ContProd {
private final EcTerms ecTerms;
private final ProdId prodId;
protected ContProdImpl(ContProd.ContProdBuilder builder) {
this.ecTerms = ofNullable(builder.getEcTerms()).map(f->f.build()).orElse(null);
this.prodId = ofNullable(builder.getProdId()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("ecTerms")
public EcTerms getEcTerms() {
return ecTerms;
}
@Override
@RosettaAttribute("prodId")
public ProdId getProdId() {
return prodId;
}
@Override
public ContProd build() {
return this;
}
@Override
public ContProd.ContProdBuilder toBuilder() {
ContProd.ContProdBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ContProd.ContProdBuilder builder) {
ofNullable(getEcTerms()).ifPresent(builder::setEcTerms);
ofNullable(getProdId()).ifPresent(builder::setProdId);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
ContProd _that = getType().cast(o);
if (!Objects.equals(ecTerms, _that.getEcTerms())) return false;
if (!Objects.equals(prodId, _that.getProdId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (ecTerms != null ? ecTerms.hashCode() : 0);
_result = 31 * _result + (prodId != null ? prodId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ContProd {" +
"ecTerms=" + this.ecTerms + ", " +
"prodId=" + this.prodId +
'}';
}
}
/*********************** Builder Implementation of ContProd ***********************/
class ContProdBuilderImpl implements ContProd.ContProdBuilder {
protected EcTerms.EcTermsBuilder ecTerms;
protected ProdId.ProdIdBuilder prodId;
public ContProdBuilderImpl() {
}
@Override
@RosettaAttribute("ecTerms")
public EcTerms.EcTermsBuilder getEcTerms() {
return ecTerms;
}
@Override
public EcTerms.EcTermsBuilder getOrCreateEcTerms() {
EcTerms.EcTermsBuilder result;
if (ecTerms!=null) {
result = ecTerms;
}
else {
result = ecTerms = EcTerms.builder();
}
return result;
}
@Override
@RosettaAttribute("prodId")
public ProdId.ProdIdBuilder getProdId() {
return prodId;
}
@Override
public ProdId.ProdIdBuilder getOrCreateProdId() {
ProdId.ProdIdBuilder result;
if (prodId!=null) {
result = prodId;
}
else {
result = prodId = ProdId.builder();
}
return result;
}
@Override
@RosettaAttribute("ecTerms")
public ContProd.ContProdBuilder setEcTerms(EcTerms ecTerms) {
this.ecTerms = ecTerms==null?null:ecTerms.toBuilder();
return this;
}
@Override
@RosettaAttribute("prodId")
public ContProd.ContProdBuilder setProdId(ProdId prodId) {
this.prodId = prodId==null?null:prodId.toBuilder();
return this;
}
@Override
public ContProd build() {
return new ContProd.ContProdImpl(this);
}
@Override
public ContProd.ContProdBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ContProd.ContProdBuilder prune() {
if (ecTerms!=null && !ecTerms.prune().hasData()) ecTerms = null;
if (prodId!=null && !prodId.prune().hasData()) prodId = null;
return this;
}
@Override
public boolean hasData() {
if (getEcTerms()!=null && getEcTerms().hasData()) return true;
if (getProdId()!=null && getProdId().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public ContProd.ContProdBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ContProd.ContProdBuilder o = (ContProd.ContProdBuilder) other;
merger.mergeRosetta(getEcTerms(), o.getEcTerms(), this::setEcTerms);
merger.mergeRosetta(getProdId(), o.getProdId(), this::setProdId);
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;
ContProd _that = getType().cast(o);
if (!Objects.equals(ecTerms, _that.getEcTerms())) return false;
if (!Objects.equals(prodId, _that.getProdId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (ecTerms != null ? ecTerms.hashCode() : 0);
_result = 31 * _result + (prodId != null ? prodId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ContProdBuilder {" +
"ecTerms=" + this.ecTerms + ", " +
"prodId=" + this.prodId +
'}';
}
}
}