com.rosetta.testconditional.model.W19_2 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_2;
import com.rosetta.testconditional.model.W19_2.W19_2Builder;
import com.rosetta.testconditional.model.W19_2.W19_2BuilderImpl;
import com.rosetta.testconditional.model.W19_2.W19_2Impl;
import com.rosetta.testconditional.model.meta.W19_2Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="W19_2", builder=W19_2.W19_2BuilderImpl.class, version="test")
public interface W19_2 extends RosettaModelObject {
W19_2Meta metaData = new W19_2Meta();
/*********************** Getter Methods ***********************/
FieldWithMetaString getXField();
/*********************** Build Methods ***********************/
W19_2 build();
W19_2.W19_2Builder toBuilder();
static W19_2.W19_2Builder builder() {
return new W19_2.W19_2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends W19_2> metaData() {
return metaData;
}
@Override
default Class extends W19_2> getType() {
return W19_2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.class, getXField());
}
/*********************** Builder Interface ***********************/
interface W19_2Builder extends W19_2, RosettaModelObjectBuilder {
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateXField();
FieldWithMetaString.FieldWithMetaStringBuilder getXField();
W19_2.W19_2Builder setXField(FieldWithMetaString xField0);
W19_2.W19_2Builder setXFieldValue(String xField1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getXField());
}
W19_2.W19_2Builder prune();
}
/*********************** Immutable Implementation of W19_2 ***********************/
class W19_2Impl implements W19_2 {
private final FieldWithMetaString xField;
protected W19_2Impl(W19_2.W19_2Builder builder) {
this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("xField")
public FieldWithMetaString getXField() {
return xField;
}
@Override
public W19_2 build() {
return this;
}
@Override
public W19_2.W19_2Builder toBuilder() {
W19_2.W19_2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(W19_2.W19_2Builder 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_2 _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_2 {" +
"xField=" + this.xField +
'}';
}
}
/*********************** Builder Implementation of W19_2 ***********************/
class W19_2BuilderImpl implements W19_2.W19_2Builder {
protected FieldWithMetaString.FieldWithMetaStringBuilder xField;
public W19_2BuilderImpl() {
}
@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_2.W19_2Builder setXField(FieldWithMetaString xField) {
this.xField = xField==null?null:xField.toBuilder();
return this;
}
@Override
public W19_2.W19_2Builder setXFieldValue(String xField) {
this.getOrCreateXField().setValue(xField);
return this;
}
@Override
public W19_2 build() {
return new W19_2.W19_2Impl(this);
}
@Override
public W19_2.W19_2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public W19_2.W19_2Builder 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_2.W19_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
W19_2.W19_2Builder o = (W19_2.W19_2Builder) 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_2 _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_2Builder {" +
"xField=" + this.xField +
'}';
}
}
}