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