com.rosetta.mappingprocessortest.model.Top10a Maven / Gradle / Ivy
package com.rosetta.mappingprocessortest.model;
import com.rosetta.mappingprocessortest.model.Top10a;
import com.rosetta.mappingprocessortest.model.Top10a.Top10aBuilder;
import com.rosetta.mappingprocessortest.model.Top10a.Top10aBuilderImpl;
import com.rosetta.mappingprocessortest.model.Top10a.Top10aImpl;
import com.rosetta.mappingprocessortest.model.Y10a;
import com.rosetta.mappingprocessortest.model.Z10a;
import com.rosetta.mappingprocessortest.model.meta.Top10aMeta;
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.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Top10a", builder=Top10a.Top10aBuilderImpl.class, version="test")
public interface Top10a extends RosettaModelObject {
Top10aMeta metaData = new Top10aMeta();
/*********************** Getter Methods ***********************/
Y10a getYField();
Z10a getZField();
/*********************** Build Methods ***********************/
Top10a build();
Top10a.Top10aBuilder toBuilder();
static Top10a.Top10aBuilder builder() {
return new Top10a.Top10aBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top10a> metaData() {
return metaData;
}
@Override
default Class extends Top10a> getType() {
return Top10a.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("yField"), processor, Y10a.class, getYField());
processRosetta(path.newSubPath("zField"), processor, Z10a.class, getZField());
}
/*********************** Builder Interface ***********************/
interface Top10aBuilder extends Top10a, RosettaModelObjectBuilder {
Y10a.Y10aBuilder getOrCreateYField();
Y10a.Y10aBuilder getYField();
Z10a.Z10aBuilder getOrCreateZField();
Z10a.Z10aBuilder getZField();
Top10a.Top10aBuilder setYField(Y10a yField);
Top10a.Top10aBuilder setZField(Z10a zField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("yField"), processor, Y10a.Y10aBuilder.class, getYField());
processRosetta(path.newSubPath("zField"), processor, Z10a.Z10aBuilder.class, getZField());
}
Top10a.Top10aBuilder prune();
}
/*********************** Immutable Implementation of Top10a ***********************/
class Top10aImpl implements Top10a {
private final Y10a yField;
private final Z10a zField;
protected Top10aImpl(Top10a.Top10aBuilder builder) {
this.yField = ofNullable(builder.getYField()).map(f->f.build()).orElse(null);
this.zField = ofNullable(builder.getZField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("yField")
public Y10a getYField() {
return yField;
}
@Override
@RosettaAttribute("zField")
public Z10a getZField() {
return zField;
}
@Override
public Top10a build() {
return this;
}
@Override
public Top10a.Top10aBuilder toBuilder() {
Top10a.Top10aBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top10a.Top10aBuilder builder) {
ofNullable(getYField()).ifPresent(builder::setYField);
ofNullable(getZField()).ifPresent(builder::setZField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top10a _that = getType().cast(o);
if (!Objects.equals(yField, _that.getYField())) return false;
if (!Objects.equals(zField, _that.getZField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (yField != null ? yField.hashCode() : 0);
_result = 31 * _result + (zField != null ? zField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top10a {" +
"yField=" + this.yField + ", " +
"zField=" + this.zField +
'}';
}
}
/*********************** Builder Implementation of Top10a ***********************/
class Top10aBuilderImpl implements Top10a.Top10aBuilder {
protected Y10a.Y10aBuilder yField;
protected Z10a.Z10aBuilder zField;
public Top10aBuilderImpl() {
}
@Override
@RosettaAttribute("yField")
public Y10a.Y10aBuilder getYField() {
return yField;
}
@Override
public Y10a.Y10aBuilder getOrCreateYField() {
Y10a.Y10aBuilder result;
if (yField!=null) {
result = yField;
}
else {
result = yField = Y10a.builder();
}
return result;
}
@Override
@RosettaAttribute("zField")
public Z10a.Z10aBuilder getZField() {
return zField;
}
@Override
public Z10a.Z10aBuilder getOrCreateZField() {
Z10a.Z10aBuilder result;
if (zField!=null) {
result = zField;
}
else {
result = zField = Z10a.builder();
}
return result;
}
@Override
@RosettaAttribute("yField")
public Top10a.Top10aBuilder setYField(Y10a yField) {
this.yField = yField==null?null:yField.toBuilder();
return this;
}
@Override
@RosettaAttribute("zField")
public Top10a.Top10aBuilder setZField(Z10a zField) {
this.zField = zField==null?null:zField.toBuilder();
return this;
}
@Override
public Top10a build() {
return new Top10a.Top10aImpl(this);
}
@Override
public Top10a.Top10aBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top10a.Top10aBuilder prune() {
if (yField!=null && !yField.prune().hasData()) yField = null;
if (zField!=null && !zField.prune().hasData()) zField = null;
return this;
}
@Override
public boolean hasData() {
if (getYField()!=null && getYField().hasData()) return true;
if (getZField()!=null && getZField().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top10a.Top10aBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top10a.Top10aBuilder o = (Top10a.Top10aBuilder) other;
merger.mergeRosetta(getYField(), o.getYField(), this::setYField);
merger.mergeRosetta(getZField(), o.getZField(), this::setZField);
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;
Top10a _that = getType().cast(o);
if (!Objects.equals(yField, _that.getYField())) return false;
if (!Objects.equals(zField, _that.getZField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (yField != null ? yField.hashCode() : 0);
_result = 31 * _result + (zField != null ? zField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top10aBuilder {" +
"yField=" + this.yField + ", " +
"zField=" + this.zField +
'}';
}
}
}