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