com.rosetta.metatest.model.PriceQuantity Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.PriceQuantity;
import com.rosetta.metatest.model.PriceQuantity.PriceQuantityBuilder;
import com.rosetta.metatest.model.PriceQuantity.PriceQuantityBuilderImpl;
import com.rosetta.metatest.model.PriceQuantity.PriceQuantityImpl;
import com.rosetta.metatest.model.Quantity;
import com.rosetta.metatest.model.meta.PriceQuantityMeta;
import com.rosetta.metatest.model.metafields.FieldWithMetaQuantity;
import com.rosetta.metatest.model.metafields.FieldWithMetaQuantity.FieldWithMetaQuantityBuilder;
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="PriceQuantity", builder=PriceQuantity.PriceQuantityBuilderImpl.class, version="test")
public interface PriceQuantity extends RosettaModelObject {
PriceQuantityMeta metaData = new PriceQuantityMeta();
/*********************** Getter Methods ***********************/
FieldWithMetaQuantity getQuantity();
/*********************** Build Methods ***********************/
PriceQuantity build();
PriceQuantity.PriceQuantityBuilder toBuilder();
static PriceQuantity.PriceQuantityBuilder builder() {
return new PriceQuantity.PriceQuantityBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends PriceQuantity> metaData() {
return metaData;
}
@Override
default Class extends PriceQuantity> getType() {
return PriceQuantity.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("quantity"), processor, FieldWithMetaQuantity.class, getQuantity());
}
/*********************** Builder Interface ***********************/
interface PriceQuantityBuilder extends PriceQuantity, RosettaModelObjectBuilder {
FieldWithMetaQuantity.FieldWithMetaQuantityBuilder getOrCreateQuantity();
FieldWithMetaQuantity.FieldWithMetaQuantityBuilder getQuantity();
PriceQuantity.PriceQuantityBuilder setQuantity(FieldWithMetaQuantity quantity0);
PriceQuantity.PriceQuantityBuilder setQuantityValue(Quantity quantity1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("quantity"), processor, FieldWithMetaQuantity.FieldWithMetaQuantityBuilder.class, getQuantity());
}
PriceQuantity.PriceQuantityBuilder prune();
}
/*********************** Immutable Implementation of PriceQuantity ***********************/
class PriceQuantityImpl implements PriceQuantity {
private final FieldWithMetaQuantity quantity;
protected PriceQuantityImpl(PriceQuantity.PriceQuantityBuilder builder) {
this.quantity = ofNullable(builder.getQuantity()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("quantity")
public FieldWithMetaQuantity getQuantity() {
return quantity;
}
@Override
public PriceQuantity build() {
return this;
}
@Override
public PriceQuantity.PriceQuantityBuilder toBuilder() {
PriceQuantity.PriceQuantityBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(PriceQuantity.PriceQuantityBuilder builder) {
ofNullable(getQuantity()).ifPresent(builder::setQuantity);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
PriceQuantity _that = getType().cast(o);
if (!Objects.equals(quantity, _that.getQuantity())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (quantity != null ? quantity.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PriceQuantity {" +
"quantity=" + this.quantity +
'}';
}
}
/*********************** Builder Implementation of PriceQuantity ***********************/
class PriceQuantityBuilderImpl implements PriceQuantity.PriceQuantityBuilder {
protected FieldWithMetaQuantity.FieldWithMetaQuantityBuilder quantity;
public PriceQuantityBuilderImpl() {
}
@Override
@RosettaAttribute("quantity")
public FieldWithMetaQuantity.FieldWithMetaQuantityBuilder getQuantity() {
return quantity;
}
@Override
public FieldWithMetaQuantity.FieldWithMetaQuantityBuilder getOrCreateQuantity() {
FieldWithMetaQuantity.FieldWithMetaQuantityBuilder result;
if (quantity!=null) {
result = quantity;
}
else {
result = quantity = FieldWithMetaQuantity.builder();
result.getOrCreateMeta().toBuilder().addKey(Key.builder().setScope("DOCUMENT"));
}
return result;
}
@Override
@RosettaAttribute("quantity")
public PriceQuantity.PriceQuantityBuilder setQuantity(FieldWithMetaQuantity quantity) {
this.quantity = quantity==null?null:quantity.toBuilder();
return this;
}
@Override
public PriceQuantity.PriceQuantityBuilder setQuantityValue(Quantity quantity) {
this.getOrCreateQuantity().setValue(quantity);
return this;
}
@Override
public PriceQuantity build() {
return new PriceQuantity.PriceQuantityImpl(this);
}
@Override
public PriceQuantity.PriceQuantityBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public PriceQuantity.PriceQuantityBuilder prune() {
if (quantity!=null && !quantity.prune().hasData()) quantity = null;
return this;
}
@Override
public boolean hasData() {
if (getQuantity()!=null && getQuantity().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public PriceQuantity.PriceQuantityBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
PriceQuantity.PriceQuantityBuilder o = (PriceQuantity.PriceQuantityBuilder) other;
merger.mergeRosetta(getQuantity(), o.getQuantity(), this::setQuantity);
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;
PriceQuantity _that = getType().cast(o);
if (!Objects.equals(quantity, _that.getQuantity())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (quantity != null ? quantity.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PriceQuantityBuilder {" +
"quantity=" + this.quantity +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy