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