com.rosetta.testother.model.A8_2 Maven / Gradle / Ivy
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.A8_2;
import com.rosetta.testother.model.A8_2.A8_2Builder;
import com.rosetta.testother.model.A8_2.A8_2BuilderImpl;
import com.rosetta.testother.model.A8_2.A8_2Impl;
import com.rosetta.testother.model.A8_3;
import com.rosetta.testother.model.meta.A8_2Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="A8_2", builder=A8_2.A8_2BuilderImpl.class, version="test")
public interface A8_2 extends RosettaModelObject {
A8_2Meta metaData = new A8_2Meta();
/*********************** Getter Methods ***********************/
A8_3 getA3Field();
/*********************** Build Methods ***********************/
A8_2 build();
A8_2.A8_2Builder toBuilder();
static A8_2.A8_2Builder builder() {
return new A8_2.A8_2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends A8_2> metaData() {
return metaData;
}
@Override
default Class extends A8_2> getType() {
return A8_2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("a3Field"), processor, A8_3.class, getA3Field());
}
/*********************** Builder Interface ***********************/
interface A8_2Builder extends A8_2, RosettaModelObjectBuilder {
A8_3.A8_3Builder getOrCreateA3Field();
A8_3.A8_3Builder getA3Field();
A8_2.A8_2Builder setA3Field(A8_3 a3Field);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("a3Field"), processor, A8_3.A8_3Builder.class, getA3Field());
}
A8_2.A8_2Builder prune();
}
/*********************** Immutable Implementation of A8_2 ***********************/
class A8_2Impl implements A8_2 {
private final A8_3 a3Field;
protected A8_2Impl(A8_2.A8_2Builder builder) {
this.a3Field = ofNullable(builder.getA3Field()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("a3Field")
public A8_3 getA3Field() {
return a3Field;
}
@Override
public A8_2 build() {
return this;
}
@Override
public A8_2.A8_2Builder toBuilder() {
A8_2.A8_2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(A8_2.A8_2Builder builder) {
ofNullable(getA3Field()).ifPresent(builder::setA3Field);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
A8_2 _that = getType().cast(o);
if (!Objects.equals(a3Field, _that.getA3Field())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (a3Field != null ? a3Field.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A8_2 {" +
"a3Field=" + this.a3Field +
'}';
}
}
/*********************** Builder Implementation of A8_2 ***********************/
class A8_2BuilderImpl implements A8_2.A8_2Builder {
protected A8_3.A8_3Builder a3Field;
public A8_2BuilderImpl() {
}
@Override
@RosettaAttribute("a3Field")
public A8_3.A8_3Builder getA3Field() {
return a3Field;
}
@Override
public A8_3.A8_3Builder getOrCreateA3Field() {
A8_3.A8_3Builder result;
if (a3Field!=null) {
result = a3Field;
}
else {
result = a3Field = A8_3.builder();
}
return result;
}
@Override
@RosettaAttribute("a3Field")
public A8_2.A8_2Builder setA3Field(A8_3 a3Field) {
this.a3Field = a3Field==null?null:a3Field.toBuilder();
return this;
}
@Override
public A8_2 build() {
return new A8_2.A8_2Impl(this);
}
@Override
public A8_2.A8_2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public A8_2.A8_2Builder prune() {
if (a3Field!=null && !a3Field.prune().hasData()) a3Field = null;
return this;
}
@Override
public boolean hasData() {
if (getA3Field()!=null && getA3Field().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public A8_2.A8_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
A8_2.A8_2Builder o = (A8_2.A8_2Builder) other;
merger.mergeRosetta(getA3Field(), o.getA3Field(), this::setA3Field);
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;
A8_2 _that = getType().cast(o);
if (!Objects.equals(a3Field, _that.getA3Field())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (a3Field != null ? a3Field.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A8_2Builder {" +
"a3Field=" + this.a3Field +
'}';
}
}
}