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