com.rosetta.testconditional.model.W2 Maven / Gradle / Ivy
package com.rosetta.testconditional.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.testconditional.model.W2;
import com.rosetta.testconditional.model.W2.W2Builder;
import com.rosetta.testconditional.model.W2.W2BuilderImpl;
import com.rosetta.testconditional.model.W2.W2Impl;
import com.rosetta.testconditional.model.Y2;
import com.rosetta.testconditional.model.meta.W2Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="W2", builder=W2.W2BuilderImpl.class, version="test")
public interface W2 extends RosettaModelObject {
W2Meta metaData = new W2Meta();
/*********************** Getter Methods ***********************/
Y2 getYField();
/*********************** Build Methods ***********************/
W2 build();
W2.W2Builder toBuilder();
static W2.W2Builder builder() {
return new W2.W2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends W2> metaData() {
return metaData;
}
@Override
default Class extends W2> getType() {
return W2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("yField"), processor, Y2.class, getYField());
}
/*********************** Builder Interface ***********************/
interface W2Builder extends W2, RosettaModelObjectBuilder {
Y2.Y2Builder getOrCreateYField();
Y2.Y2Builder getYField();
W2.W2Builder setYField(Y2 yField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("yField"), processor, Y2.Y2Builder.class, getYField());
}
W2.W2Builder prune();
}
/*********************** Immutable Implementation of W2 ***********************/
class W2Impl implements W2 {
private final Y2 yField;
protected W2Impl(W2.W2Builder builder) {
this.yField = ofNullable(builder.getYField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("yField")
public Y2 getYField() {
return yField;
}
@Override
public W2 build() {
return this;
}
@Override
public W2.W2Builder toBuilder() {
W2.W2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(W2.W2Builder 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;
W2 _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 "W2 {" +
"yField=" + this.yField +
'}';
}
}
/*********************** Builder Implementation of W2 ***********************/
class W2BuilderImpl implements W2.W2Builder {
protected Y2.Y2Builder yField;
public W2BuilderImpl() {
}
@Override
@RosettaAttribute("yField")
public Y2.Y2Builder getYField() {
return yField;
}
@Override
public Y2.Y2Builder getOrCreateYField() {
Y2.Y2Builder result;
if (yField!=null) {
result = yField;
}
else {
result = yField = Y2.builder();
}
return result;
}
@Override
@RosettaAttribute("yField")
public W2.W2Builder setYField(Y2 yField) {
this.yField = yField==null?null:yField.toBuilder();
return this;
}
@Override
public W2 build() {
return new W2.W2Impl(this);
}
@Override
public W2.W2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public W2.W2Builder 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 W2.W2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
W2.W2Builder o = (W2.W2Builder) 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;
W2 _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 "W2Builder {" +
"yField=" + this.yField +
'}';
}
}
}