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