com.rosetta.metatest.model.Quantity Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.Quantity;
import com.rosetta.metatest.model.Quantity.QuantityBuilder;
import com.rosetta.metatest.model.Quantity.QuantityBuilderImpl;
import com.rosetta.metatest.model.Quantity.QuantityImpl;
import com.rosetta.metatest.model.meta.QuantityMeta;
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.math.BigDecimal;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Quantity", builder=Quantity.QuantityBuilderImpl.class, version="test")
public interface Quantity extends RosettaModelObject {
QuantityMeta metaData = new QuantityMeta();
/*********************** Getter Methods ***********************/
BigDecimal getAmount();
/*********************** Build Methods ***********************/
Quantity build();
Quantity.QuantityBuilder toBuilder();
static Quantity.QuantityBuilder builder() {
return new Quantity.QuantityBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Quantity> metaData() {
return metaData;
}
@Override
default Class extends Quantity> getType() {
return Quantity.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("amount"), BigDecimal.class, getAmount(), this);
}
/*********************** Builder Interface ***********************/
interface QuantityBuilder extends Quantity, RosettaModelObjectBuilder {
Quantity.QuantityBuilder setAmount(BigDecimal amount);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("amount"), BigDecimal.class, getAmount(), this);
}
Quantity.QuantityBuilder prune();
}
/*********************** Immutable Implementation of Quantity ***********************/
class QuantityImpl implements Quantity {
private final BigDecimal amount;
protected QuantityImpl(Quantity.QuantityBuilder builder) {
this.amount = builder.getAmount();
}
@Override
@RosettaAttribute("amount")
public BigDecimal getAmount() {
return amount;
}
@Override
public Quantity build() {
return this;
}
@Override
public Quantity.QuantityBuilder toBuilder() {
Quantity.QuantityBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Quantity.QuantityBuilder builder) {
ofNullable(getAmount()).ifPresent(builder::setAmount);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Quantity _that = getType().cast(o);
if (!Objects.equals(amount, _that.getAmount())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (amount != null ? amount.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Quantity {" +
"amount=" + this.amount +
'}';
}
}
/*********************** Builder Implementation of Quantity ***********************/
class QuantityBuilderImpl implements Quantity.QuantityBuilder {
protected BigDecimal amount;
public QuantityBuilderImpl() {
}
@Override
@RosettaAttribute("amount")
public BigDecimal getAmount() {
return amount;
}
@Override
@RosettaAttribute("amount")
public Quantity.QuantityBuilder setAmount(BigDecimal amount) {
this.amount = amount==null?null:amount;
return this;
}
@Override
public Quantity build() {
return new Quantity.QuantityImpl(this);
}
@Override
public Quantity.QuantityBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Quantity.QuantityBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getAmount()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Quantity.QuantityBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Quantity.QuantityBuilder o = (Quantity.QuantityBuilder) other;
merger.mergeBasic(getAmount(), o.getAmount(), this::setAmount);
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;
Quantity _that = getType().cast(o);
if (!Objects.equals(amount, _that.getAmount())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (amount != null ? amount.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "QuantityBuilder {" +
"amount=" + this.amount +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy