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