com.rosetta.teststruct.model.B2 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.B2;
import com.rosetta.teststruct.model.B2.B2Builder;
import com.rosetta.teststruct.model.B2.B2BuilderImpl;
import com.rosetta.teststruct.model.B2.B2Impl;
import com.rosetta.teststruct.model.meta.B2Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="B2", builder=B2.B2BuilderImpl.class, version="test")
public interface B2 extends RosettaModelObject {
B2Meta metaData = new B2Meta();
/*********************** Getter Methods ***********************/
String getCField();
/*********************** Build Methods ***********************/
B2 build();
B2.B2Builder toBuilder();
static B2.B2Builder builder() {
return new B2.B2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends B2> metaData() {
return metaData;
}
@Override
default Class extends B2> getType() {
return B2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("cField"), String.class, getCField(), this);
}
/*********************** Builder Interface ***********************/
interface B2Builder extends B2, RosettaModelObjectBuilder {
B2.B2Builder setCField(String cField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("cField"), String.class, getCField(), this);
}
B2.B2Builder prune();
}
/*********************** Immutable Implementation of B2 ***********************/
class B2Impl implements B2 {
private final String cField;
protected B2Impl(B2.B2Builder builder) {
this.cField = builder.getCField();
}
@Override
@RosettaAttribute("cField")
public String getCField() {
return cField;
}
@Override
public B2 build() {
return this;
}
@Override
public B2.B2Builder toBuilder() {
B2.B2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(B2.B2Builder 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;
B2 _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 "B2 {" +
"cField=" + this.cField +
'}';
}
}
/*********************** Builder Implementation of B2 ***********************/
class B2BuilderImpl implements B2.B2Builder {
protected String cField;
public B2BuilderImpl() {
}
@Override
@RosettaAttribute("cField")
public String getCField() {
return cField;
}
@Override
@RosettaAttribute("cField")
public B2.B2Builder setCField(String cField) {
this.cField = cField==null?null:cField;
return this;
}
@Override
public B2 build() {
return new B2.B2Impl(this);
}
@Override
public B2.B2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public B2.B2Builder prune() {
return this;
}
@Override
public boolean hasData() {
if (getCField()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public B2.B2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
B2.B2Builder o = (B2.B2Builder) other;
merger.mergeBasic(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;
B2 _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 "B2Builder {" +
"cField=" + this.cField +
'}';
}
}
}