com.rosetta.mappingprocessortest.model.Top10c Maven / Gradle / Ivy
package com.rosetta.mappingprocessortest.model;
import com.rosetta.mappingprocessortest.model.Top10c;
import com.rosetta.mappingprocessortest.model.Top10c.Top10cBuilder;
import com.rosetta.mappingprocessortest.model.Top10c.Top10cBuilderImpl;
import com.rosetta.mappingprocessortest.model.Top10c.Top10cImpl;
import com.rosetta.mappingprocessortest.model.Y10c;
import com.rosetta.mappingprocessortest.model.Z10c;
import com.rosetta.mappingprocessortest.model.meta.Top10cMeta;
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="Top10c", builder=Top10c.Top10cBuilderImpl.class, version="test")
public interface Top10c extends RosettaModelObject {
Top10cMeta metaData = new Top10cMeta();
/*********************** Getter Methods ***********************/
Y10c getYField();
Z10c getZField();
/*********************** Build Methods ***********************/
Top10c build();
Top10c.Top10cBuilder toBuilder();
static Top10c.Top10cBuilder builder() {
return new Top10c.Top10cBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top10c> metaData() {
return metaData;
}
@Override
default Class extends Top10c> getType() {
return Top10c.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("yField"), processor, Y10c.class, getYField());
processRosetta(path.newSubPath("zField"), processor, Z10c.class, getZField());
}
/*********************** Builder Interface ***********************/
interface Top10cBuilder extends Top10c, RosettaModelObjectBuilder {
Y10c.Y10cBuilder getOrCreateYField();
Y10c.Y10cBuilder getYField();
Z10c.Z10cBuilder getOrCreateZField();
Z10c.Z10cBuilder getZField();
Top10c.Top10cBuilder setYField(Y10c yField);
Top10c.Top10cBuilder setZField(Z10c zField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("yField"), processor, Y10c.Y10cBuilder.class, getYField());
processRosetta(path.newSubPath("zField"), processor, Z10c.Z10cBuilder.class, getZField());
}
Top10c.Top10cBuilder prune();
}
/*********************** Immutable Implementation of Top10c ***********************/
class Top10cImpl implements Top10c {
private final Y10c yField;
private final Z10c zField;
protected Top10cImpl(Top10c.Top10cBuilder 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 Y10c getYField() {
return yField;
}
@Override
@RosettaAttribute("zField")
public Z10c getZField() {
return zField;
}
@Override
public Top10c build() {
return this;
}
@Override
public Top10c.Top10cBuilder toBuilder() {
Top10c.Top10cBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top10c.Top10cBuilder 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;
Top10c _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 "Top10c {" +
"yField=" + this.yField + ", " +
"zField=" + this.zField +
'}';
}
}
/*********************** Builder Implementation of Top10c ***********************/
class Top10cBuilderImpl implements Top10c.Top10cBuilder {
protected Y10c.Y10cBuilder yField;
protected Z10c.Z10cBuilder zField;
public Top10cBuilderImpl() {
}
@Override
@RosettaAttribute("yField")
public Y10c.Y10cBuilder getYField() {
return yField;
}
@Override
public Y10c.Y10cBuilder getOrCreateYField() {
Y10c.Y10cBuilder result;
if (yField!=null) {
result = yField;
}
else {
result = yField = Y10c.builder();
}
return result;
}
@Override
@RosettaAttribute("zField")
public Z10c.Z10cBuilder getZField() {
return zField;
}
@Override
public Z10c.Z10cBuilder getOrCreateZField() {
Z10c.Z10cBuilder result;
if (zField!=null) {
result = zField;
}
else {
result = zField = Z10c.builder();
}
return result;
}
@Override
@RosettaAttribute("yField")
public Top10c.Top10cBuilder setYField(Y10c yField) {
this.yField = yField==null?null:yField.toBuilder();
return this;
}
@Override
@RosettaAttribute("zField")
public Top10c.Top10cBuilder setZField(Z10c zField) {
this.zField = zField==null?null:zField.toBuilder();
return this;
}
@Override
public Top10c build() {
return new Top10c.Top10cImpl(this);
}
@Override
public Top10c.Top10cBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top10c.Top10cBuilder 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 Top10c.Top10cBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top10c.Top10cBuilder o = (Top10c.Top10cBuilder) 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;
Top10c _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 "Top10cBuilder {" +
"yField=" + this.yField + ", " +
"zField=" + this.zField +
'}';
}
}
}