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