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