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