com.rosetta.testconditional.model.W19_1 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.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
import com.rosetta.testconditional.model.W19_1;
import com.rosetta.testconditional.model.W19_1.W19_1Builder;
import com.rosetta.testconditional.model.W19_1.W19_1BuilderImpl;
import com.rosetta.testconditional.model.W19_1.W19_1Impl;
import com.rosetta.testconditional.model.meta.W19_1Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="W19_1", builder=W19_1.W19_1BuilderImpl.class, version="test")
public interface W19_1 extends RosettaModelObject {
W19_1Meta metaData = new W19_1Meta();
/*********************** Getter Methods ***********************/
FieldWithMetaString getXField();
/*********************** Build Methods ***********************/
W19_1 build();
W19_1.W19_1Builder toBuilder();
static W19_1.W19_1Builder builder() {
return new W19_1.W19_1BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends W19_1> metaData() {
return metaData;
}
@Override
default Class extends W19_1> getType() {
return W19_1.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.class, getXField());
}
/*********************** Builder Interface ***********************/
interface W19_1Builder extends W19_1, RosettaModelObjectBuilder {
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateXField();
FieldWithMetaString.FieldWithMetaStringBuilder getXField();
W19_1.W19_1Builder setXField(FieldWithMetaString xField0);
W19_1.W19_1Builder setXFieldValue(String xField1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getXField());
}
W19_1.W19_1Builder prune();
}
/*********************** Immutable Implementation of W19_1 ***********************/
class W19_1Impl implements W19_1 {
private final FieldWithMetaString xField;
protected W19_1Impl(W19_1.W19_1Builder builder) {
this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("xField")
public FieldWithMetaString getXField() {
return xField;
}
@Override
public W19_1 build() {
return this;
}
@Override
public W19_1.W19_1Builder toBuilder() {
W19_1.W19_1Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(W19_1.W19_1Builder builder) {
ofNullable(getXField()).ifPresent(builder::setXField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
W19_1 _that = getType().cast(o);
if (!Objects.equals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "W19_1 {" +
"xField=" + this.xField +
'}';
}
}
/*********************** Builder Implementation of W19_1 ***********************/
class W19_1BuilderImpl implements W19_1.W19_1Builder {
protected FieldWithMetaString.FieldWithMetaStringBuilder xField;
public W19_1BuilderImpl() {
}
@Override
@RosettaAttribute("xField")
public FieldWithMetaString.FieldWithMetaStringBuilder getXField() {
return xField;
}
@Override
public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateXField() {
FieldWithMetaString.FieldWithMetaStringBuilder result;
if (xField!=null) {
result = xField;
}
else {
result = xField = FieldWithMetaString.builder();
}
return result;
}
@Override
@RosettaAttribute("xField")
public W19_1.W19_1Builder setXField(FieldWithMetaString xField) {
this.xField = xField==null?null:xField.toBuilder();
return this;
}
@Override
public W19_1.W19_1Builder setXFieldValue(String xField) {
this.getOrCreateXField().setValue(xField);
return this;
}
@Override
public W19_1 build() {
return new W19_1.W19_1Impl(this);
}
@Override
public W19_1.W19_1Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public W19_1.W19_1Builder prune() {
if (xField!=null && !xField.prune().hasData()) xField = null;
return this;
}
@Override
public boolean hasData() {
if (getXField()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public W19_1.W19_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
W19_1.W19_1Builder o = (W19_1.W19_1Builder) other;
merger.mergeRosetta(getXField(), o.getXField(), this::setXField);
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;
W19_1 _that = getType().cast(o);
if (!Objects.equals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "W19_1Builder {" +
"xField=" + this.xField +
'}';
}
}
}