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