com.rosetta.testother.model.A4 Maven / Gradle / Ivy
The newest version!
package com.rosetta.testother.model;
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.testother.model.A4;
import com.rosetta.testother.model.A4.A4Builder;
import com.rosetta.testother.model.A4.A4BuilderImpl;
import com.rosetta.testother.model.A4.A4Impl;
import com.rosetta.testother.model.X4;
import com.rosetta.testother.model.X4.X4Builder;
import com.rosetta.testother.model.meta.A4Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="A4", builder=A4.A4BuilderImpl.class, version="test")
public interface A4 extends RosettaModelObject {
A4Meta metaData = new A4Meta();
/*********************** Getter Methods ***********************/
String getBField();
X4 getXField();
/*********************** Build Methods ***********************/
A4 build();
A4.A4Builder toBuilder();
static A4.A4Builder builder() {
return new A4.A4BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends A4> metaData() {
return metaData;
}
@Override
default Class extends A4> getType() {
return A4.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("bField"), String.class, getBField(), this);
processRosetta(path.newSubPath("xField"), processor, X4.class, getXField());
}
/*********************** Builder Interface ***********************/
interface A4Builder extends A4, RosettaModelObjectBuilder {
X4.X4Builder getOrCreateXField();
@Override
X4.X4Builder getXField();
A4.A4Builder setBField(String bField);
A4.A4Builder setXField(X4 xField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("bField"), String.class, getBField(), this);
processRosetta(path.newSubPath("xField"), processor, X4.X4Builder.class, getXField());
}
A4.A4Builder prune();
}
/*********************** Immutable Implementation of A4 ***********************/
class A4Impl implements A4 {
private final String bField;
private final X4 xField;
protected A4Impl(A4.A4Builder builder) {
this.bField = builder.getBField();
this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("bField")
public String getBField() {
return bField;
}
@Override
@RosettaAttribute("xField")
public X4 getXField() {
return xField;
}
@Override
public A4 build() {
return this;
}
@Override
public A4.A4Builder toBuilder() {
A4.A4Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(A4.A4Builder builder) {
ofNullable(getBField()).ifPresent(builder::setBField);
ofNullable(getXField()).ifPresent(builder::setXField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
A4 _that = getType().cast(o);
if (!Objects.equals(bField, _that.getBField())) return false;
if (!Objects.equals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (bField != null ? bField.hashCode() : 0);
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A4 {" +
"bField=" + this.bField + ", " +
"xField=" + this.xField +
'}';
}
}
/*********************** Builder Implementation of A4 ***********************/
class A4BuilderImpl implements A4.A4Builder {
protected String bField;
protected X4.X4Builder xField;
@Override
@RosettaAttribute("bField")
public String getBField() {
return bField;
}
@Override
@RosettaAttribute("xField")
public X4.X4Builder getXField() {
return xField;
}
@Override
public X4.X4Builder getOrCreateXField() {
X4.X4Builder result;
if (xField!=null) {
result = xField;
}
else {
result = xField = X4.builder();
}
return result;
}
@Override
@RosettaAttribute("bField")
public A4.A4Builder setBField(String _bField) {
this.bField = _bField == null ? null : _bField;
return this;
}
@Override
@RosettaAttribute("xField")
public A4.A4Builder setXField(X4 _xField) {
this.xField = _xField == null ? null : _xField.toBuilder();
return this;
}
@Override
public A4 build() {
return new A4.A4Impl(this);
}
@Override
public A4.A4Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public A4.A4Builder prune() {
if (xField!=null && !xField.prune().hasData()) xField = null;
return this;
}
@Override
public boolean hasData() {
if (getBField()!=null) return true;
if (getXField()!=null && getXField().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public A4.A4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
A4.A4Builder o = (A4.A4Builder) other;
merger.mergeRosetta(getXField(), o.getXField(), this::setXField);
merger.mergeBasic(getBField(), o.getBField(), this::setBField);
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;
A4 _that = getType().cast(o);
if (!Objects.equals(bField, _that.getBField())) return false;
if (!Objects.equals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (bField != null ? bField.hashCode() : 0);
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A4Builder {" +
"bField=" + this.bField + ", " +
"xField=" + this.xField +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy