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