com.rosetta.metatest.model.Top14 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.PriceQuantity14;
import com.rosetta.metatest.model.ResolvableAsset14;
import com.rosetta.metatest.model.Top14;
import com.rosetta.metatest.model.Top14.Top14Builder;
import com.rosetta.metatest.model.Top14.Top14BuilderImpl;
import com.rosetta.metatest.model.Top14.Top14Impl;
import com.rosetta.metatest.model.meta.Top14Meta;
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="Top14", builder=Top14.Top14BuilderImpl.class, version="test")
public interface Top14 extends RosettaModelObject {
Top14Meta metaData = new Top14Meta();
/*********************** Getter Methods ***********************/
PriceQuantity14 getPq();
ResolvableAsset14 getRpq();
/*********************** Build Methods ***********************/
Top14 build();
Top14.Top14Builder toBuilder();
static Top14.Top14Builder builder() {
return new Top14.Top14BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top14> metaData() {
return metaData;
}
@Override
default Class extends Top14> getType() {
return Top14.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("pq"), processor, PriceQuantity14.class, getPq());
processRosetta(path.newSubPath("rpq"), processor, ResolvableAsset14.class, getRpq());
}
/*********************** Builder Interface ***********************/
interface Top14Builder extends Top14, RosettaModelObjectBuilder {
PriceQuantity14.PriceQuantity14Builder getOrCreatePq();
PriceQuantity14.PriceQuantity14Builder getPq();
ResolvableAsset14.ResolvableAsset14Builder getOrCreateRpq();
ResolvableAsset14.ResolvableAsset14Builder getRpq();
Top14.Top14Builder setPq(PriceQuantity14 pq);
Top14.Top14Builder setRpq(ResolvableAsset14 rpq);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("pq"), processor, PriceQuantity14.PriceQuantity14Builder.class, getPq());
processRosetta(path.newSubPath("rpq"), processor, ResolvableAsset14.ResolvableAsset14Builder.class, getRpq());
}
Top14.Top14Builder prune();
}
/*********************** Immutable Implementation of Top14 ***********************/
class Top14Impl implements Top14 {
private final PriceQuantity14 pq;
private final ResolvableAsset14 rpq;
protected Top14Impl(Top14.Top14Builder builder) {
this.pq = ofNullable(builder.getPq()).map(f->f.build()).orElse(null);
this.rpq = ofNullable(builder.getRpq()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("pq")
public PriceQuantity14 getPq() {
return pq;
}
@Override
@RosettaAttribute("rpq")
public ResolvableAsset14 getRpq() {
return rpq;
}
@Override
public Top14 build() {
return this;
}
@Override
public Top14.Top14Builder toBuilder() {
Top14.Top14Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top14.Top14Builder builder) {
ofNullable(getPq()).ifPresent(builder::setPq);
ofNullable(getRpq()).ifPresent(builder::setRpq);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top14 _that = getType().cast(o);
if (!Objects.equals(pq, _that.getPq())) return false;
if (!Objects.equals(rpq, _that.getRpq())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (pq != null ? pq.hashCode() : 0);
_result = 31 * _result + (rpq != null ? rpq.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top14 {" +
"pq=" + this.pq + ", " +
"rpq=" + this.rpq +
'}';
}
}
/*********************** Builder Implementation of Top14 ***********************/
class Top14BuilderImpl implements Top14.Top14Builder {
protected PriceQuantity14.PriceQuantity14Builder pq;
protected ResolvableAsset14.ResolvableAsset14Builder rpq;
public Top14BuilderImpl() {
}
@Override
@RosettaAttribute("pq")
public PriceQuantity14.PriceQuantity14Builder getPq() {
return pq;
}
@Override
public PriceQuantity14.PriceQuantity14Builder getOrCreatePq() {
PriceQuantity14.PriceQuantity14Builder result;
if (pq!=null) {
result = pq;
}
else {
result = pq = PriceQuantity14.builder();
}
return result;
}
@Override
@RosettaAttribute("rpq")
public ResolvableAsset14.ResolvableAsset14Builder getRpq() {
return rpq;
}
@Override
public ResolvableAsset14.ResolvableAsset14Builder getOrCreateRpq() {
ResolvableAsset14.ResolvableAsset14Builder result;
if (rpq!=null) {
result = rpq;
}
else {
result = rpq = ResolvableAsset14.builder();
}
return result;
}
@Override
@RosettaAttribute("pq")
public Top14.Top14Builder setPq(PriceQuantity14 pq) {
this.pq = pq==null?null:pq.toBuilder();
return this;
}
@Override
@RosettaAttribute("rpq")
public Top14.Top14Builder setRpq(ResolvableAsset14 rpq) {
this.rpq = rpq==null?null:rpq.toBuilder();
return this;
}
@Override
public Top14 build() {
return new Top14.Top14Impl(this);
}
@Override
public Top14.Top14Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top14.Top14Builder prune() {
if (pq!=null && !pq.prune().hasData()) pq = null;
if (rpq!=null && !rpq.prune().hasData()) rpq = null;
return this;
}
@Override
public boolean hasData() {
if (getPq()!=null && getPq().hasData()) return true;
if (getRpq()!=null && getRpq().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top14.Top14Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top14.Top14Builder o = (Top14.Top14Builder) other;
merger.mergeRosetta(getPq(), o.getPq(), this::setPq);
merger.mergeRosetta(getRpq(), o.getRpq(), this::setRpq);
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;
Top14 _that = getType().cast(o);
if (!Objects.equals(pq, _that.getPq())) return false;
if (!Objects.equals(rpq, _that.getRpq())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (pq != null ? pq.hashCode() : 0);
_result = 31 * _result + (rpq != null ? rpq.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top14Builder {" +
"pq=" + this.pq + ", " +
"rpq=" + this.rpq +
'}';
}
}
}