com.rosetta.teststruct.model.D5 Maven / Gradle / Ivy
package com.rosetta.teststruct.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.teststruct.model.C5;
import com.rosetta.teststruct.model.D5;
import com.rosetta.teststruct.model.D5.D5Builder;
import com.rosetta.teststruct.model.D5.D5BuilderImpl;
import com.rosetta.teststruct.model.D5.D5Impl;
import com.rosetta.teststruct.model.meta.D5Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="D5", builder=D5.D5BuilderImpl.class, version="test")
public interface D5 extends RosettaModelObject {
D5Meta metaData = new D5Meta();
/*********************** Getter Methods ***********************/
C5 getCField();
/*********************** Build Methods ***********************/
D5 build();
D5.D5Builder toBuilder();
static D5.D5Builder builder() {
return new D5.D5BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends D5> metaData() {
return metaData;
}
@Override
default Class extends D5> getType() {
return D5.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("cField"), processor, C5.class, getCField());
}
/*********************** Builder Interface ***********************/
interface D5Builder extends D5, RosettaModelObjectBuilder {
C5.C5Builder getOrCreateCField();
C5.C5Builder getCField();
D5.D5Builder setCField(C5 cField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("cField"), processor, C5.C5Builder.class, getCField());
}
D5.D5Builder prune();
}
/*********************** Immutable Implementation of D5 ***********************/
class D5Impl implements D5 {
private final C5 cField;
protected D5Impl(D5.D5Builder builder) {
this.cField = ofNullable(builder.getCField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("cField")
public C5 getCField() {
return cField;
}
@Override
public D5 build() {
return this;
}
@Override
public D5.D5Builder toBuilder() {
D5.D5Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(D5.D5Builder builder) {
ofNullable(getCField()).ifPresent(builder::setCField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
D5 _that = getType().cast(o);
if (!Objects.equals(cField, _that.getCField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "D5 {" +
"cField=" + this.cField +
'}';
}
}
/*********************** Builder Implementation of D5 ***********************/
class D5BuilderImpl implements D5.D5Builder {
protected C5.C5Builder cField;
public D5BuilderImpl() {
}
@Override
@RosettaAttribute("cField")
public C5.C5Builder getCField() {
return cField;
}
@Override
public C5.C5Builder getOrCreateCField() {
C5.C5Builder result;
if (cField!=null) {
result = cField;
}
else {
result = cField = C5.builder();
}
return result;
}
@Override
@RosettaAttribute("cField")
public D5.D5Builder setCField(C5 cField) {
this.cField = cField==null?null:cField.toBuilder();
return this;
}
@Override
public D5 build() {
return new D5.D5Impl(this);
}
@Override
public D5.D5Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public D5.D5Builder prune() {
if (cField!=null && !cField.prune().hasData()) cField = null;
return this;
}
@Override
public boolean hasData() {
if (getCField()!=null && getCField().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public D5.D5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
D5.D5Builder o = (D5.D5Builder) other;
merger.mergeRosetta(getCField(), o.getCField(), this::setCField);
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;
D5 _that = getType().cast(o);
if (!Objects.equals(cField, _that.getCField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "D5Builder {" +
"cField=" + this.cField +
'}';
}
}
}