com.rosetta.metatest.model.PriceQuantity13 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.Observable13;
import com.rosetta.metatest.model.PriceQuantity13;
import com.rosetta.metatest.model.PriceQuantity13.PriceQuantity13Builder;
import com.rosetta.metatest.model.PriceQuantity13.PriceQuantity13BuilderImpl;
import com.rosetta.metatest.model.PriceQuantity13.PriceQuantity13Impl;
import com.rosetta.metatest.model.meta.PriceQuantity13Meta;
import com.rosetta.metatest.model.metafields.FieldWithMetaObservable13;
import com.rosetta.metatest.model.metafields.FieldWithMetaObservable13.FieldWithMetaObservable13Builder;
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.Key;
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="PriceQuantity13", builder=PriceQuantity13.PriceQuantity13BuilderImpl.class, version="test")
public interface PriceQuantity13 extends RosettaModelObject {
PriceQuantity13Meta metaData = new PriceQuantity13Meta();
/*********************** Getter Methods ***********************/
FieldWithMetaObservable13 getObservable();
/*********************** Build Methods ***********************/
PriceQuantity13 build();
PriceQuantity13.PriceQuantity13Builder toBuilder();
static PriceQuantity13.PriceQuantity13Builder builder() {
return new PriceQuantity13.PriceQuantity13BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends PriceQuantity13> metaData() {
return metaData;
}
@Override
default Class extends PriceQuantity13> getType() {
return PriceQuantity13.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("observable"), processor, FieldWithMetaObservable13.class, getObservable());
}
/*********************** Builder Interface ***********************/
interface PriceQuantity13Builder extends PriceQuantity13, RosettaModelObjectBuilder {
FieldWithMetaObservable13.FieldWithMetaObservable13Builder getOrCreateObservable();
FieldWithMetaObservable13.FieldWithMetaObservable13Builder getObservable();
PriceQuantity13.PriceQuantity13Builder setObservable(FieldWithMetaObservable13 observable0);
PriceQuantity13.PriceQuantity13Builder setObservableValue(Observable13 observable1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("observable"), processor, FieldWithMetaObservable13.FieldWithMetaObservable13Builder.class, getObservable());
}
PriceQuantity13.PriceQuantity13Builder prune();
}
/*********************** Immutable Implementation of PriceQuantity13 ***********************/
class PriceQuantity13Impl implements PriceQuantity13 {
private final FieldWithMetaObservable13 observable;
protected PriceQuantity13Impl(PriceQuantity13.PriceQuantity13Builder builder) {
this.observable = ofNullable(builder.getObservable()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("observable")
public FieldWithMetaObservable13 getObservable() {
return observable;
}
@Override
public PriceQuantity13 build() {
return this;
}
@Override
public PriceQuantity13.PriceQuantity13Builder toBuilder() {
PriceQuantity13.PriceQuantity13Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(PriceQuantity13.PriceQuantity13Builder builder) {
ofNullable(getObservable()).ifPresent(builder::setObservable);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
PriceQuantity13 _that = getType().cast(o);
if (!Objects.equals(observable, _that.getObservable())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (observable != null ? observable.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PriceQuantity13 {" +
"observable=" + this.observable +
'}';
}
}
/*********************** Builder Implementation of PriceQuantity13 ***********************/
class PriceQuantity13BuilderImpl implements PriceQuantity13.PriceQuantity13Builder {
protected FieldWithMetaObservable13.FieldWithMetaObservable13Builder observable;
public PriceQuantity13BuilderImpl() {
}
@Override
@RosettaAttribute("observable")
public FieldWithMetaObservable13.FieldWithMetaObservable13Builder getObservable() {
return observable;
}
@Override
public FieldWithMetaObservable13.FieldWithMetaObservable13Builder getOrCreateObservable() {
FieldWithMetaObservable13.FieldWithMetaObservable13Builder result;
if (observable!=null) {
result = observable;
}
else {
result = observable = FieldWithMetaObservable13.builder();
result.getOrCreateMeta().toBuilder().addKey(Key.builder().setScope("DOCUMENT"));
}
return result;
}
@Override
@RosettaAttribute("observable")
public PriceQuantity13.PriceQuantity13Builder setObservable(FieldWithMetaObservable13 observable) {
this.observable = observable==null?null:observable.toBuilder();
return this;
}
@Override
public PriceQuantity13.PriceQuantity13Builder setObservableValue(Observable13 observable) {
this.getOrCreateObservable().setValue(observable);
return this;
}
@Override
public PriceQuantity13 build() {
return new PriceQuantity13.PriceQuantity13Impl(this);
}
@Override
public PriceQuantity13.PriceQuantity13Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public PriceQuantity13.PriceQuantity13Builder prune() {
if (observable!=null && !observable.prune().hasData()) observable = null;
return this;
}
@Override
public boolean hasData() {
if (getObservable()!=null && getObservable().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public PriceQuantity13.PriceQuantity13Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
PriceQuantity13.PriceQuantity13Builder o = (PriceQuantity13.PriceQuantity13Builder) other;
merger.mergeRosetta(getObservable(), o.getObservable(), this::setObservable);
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;
PriceQuantity13 _that = getType().cast(o);
if (!Objects.equals(observable, _that.getObservable())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (observable != null ? observable.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PriceQuantity13Builder {" +
"observable=" + this.observable +
'}';
}
}
}