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