com.rosetta.extended.model.A2 Maven / Gradle / Ivy
package com.rosetta.extended.model;
import com.rosetta.extended.model.A2;
import com.rosetta.extended.model.A2.A2Builder;
import com.rosetta.extended.model.A2.A2BuilderImpl;
import com.rosetta.extended.model.A2.A2Impl;
import com.rosetta.extended.model.meta.A2Meta;
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.model.metafields.MetaFields;
import com.rosetta.roota.model.A1;
import com.rosetta.roota.model.A1.A1Builder;
import com.rosetta.roota.model.A1.A1BuilderImpl;
import com.rosetta.roota.model.A1.A1Impl;
import com.rosetta.roota.model.X1;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="A2", builder=A2.A2BuilderImpl.class, version="test")
public interface A2 extends A1 {
A2Meta metaData = new A2Meta();
/*********************** Getter Methods ***********************/
String getAVal();
/*********************** Build Methods ***********************/
A2 build();
A2.A2Builder toBuilder();
static A2.A2Builder builder() {
return new A2.A2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends A2> metaData() {
return metaData;
}
@Override
default Class extends A2> getType() {
return A2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("xField"), processor, X1.class, getXField());
processRosetta(path.newSubPath("meta"), processor, MetaFields.class, getMeta());
processor.processBasic(path.newSubPath("aVal"), String.class, getAVal(), this);
}
/*********************** Builder Interface ***********************/
interface A2Builder extends A2, A1.A1Builder {
A2.A2Builder setXField(X1 xField);
A2.A2Builder setMeta(MetaFields meta);
A2.A2Builder setAVal(String aVal);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("xField"), processor, X1.X1Builder.class, getXField());
processRosetta(path.newSubPath("meta"), processor, MetaFields.MetaFieldsBuilder.class, getMeta());
processor.processBasic(path.newSubPath("aVal"), String.class, getAVal(), this);
}
A2.A2Builder prune();
}
/*********************** Immutable Implementation of A2 ***********************/
class A2Impl extends A1.A1Impl implements A2 {
private final String aVal;
protected A2Impl(A2.A2Builder builder) {
super(builder);
this.aVal = builder.getAVal();
}
@Override
@RosettaAttribute("aVal")
public String getAVal() {
return aVal;
}
@Override
public A2 build() {
return this;
}
@Override
public A2.A2Builder toBuilder() {
A2.A2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(A2.A2Builder builder) {
super.setBuilderFields(builder);
ofNullable(getAVal()).ifPresent(builder::setAVal);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
if (!super.equals(o)) return false;
A2 _that = getType().cast(o);
if (!Objects.equals(aVal, _that.getAVal())) return false;
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (aVal != null ? aVal.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A2 {" +
"aVal=" + this.aVal +
'}' + " " + super.toString();
}
}
/*********************** Builder Implementation of A2 ***********************/
class A2BuilderImpl extends A1.A1BuilderImpl implements A2.A2Builder {
protected String aVal;
public A2BuilderImpl() {
}
@Override
@RosettaAttribute("aVal")
public String getAVal() {
return aVal;
}
@Override
@RosettaAttribute("xField")
public A2.A2Builder setXField(X1 xField) {
this.xField = xField==null?null:xField.toBuilder();
return this;
}
@Override
@RosettaAttribute("meta")
public A2.A2Builder setMeta(MetaFields meta) {
this.meta = meta==null?null:meta.toBuilder();
return this;
}
@Override
@RosettaAttribute("aVal")
public A2.A2Builder setAVal(String aVal) {
this.aVal = aVal==null?null:aVal;
return this;
}
@Override
public A2 build() {
return new A2.A2Impl(this);
}
@Override
public A2.A2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public A2.A2Builder prune() {
super.prune();
return this;
}
@Override
public boolean hasData() {
if (super.hasData()) return true;
if (getAVal()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public A2.A2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
super.merge(other, merger);
A2.A2Builder o = (A2.A2Builder) other;
merger.mergeBasic(getAVal(), o.getAVal(), this::setAVal);
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;
if (!super.equals(o)) return false;
A2 _that = getType().cast(o);
if (!Objects.equals(aVal, _that.getAVal())) return false;
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (aVal != null ? aVal.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A2Builder {" +
"aVal=" + this.aVal +
'}' + " " + super.toString();
}
}
}