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