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