com.rosetta.test.conditionfunc.model.Z2 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.Z2;
import com.rosetta.test.conditionfunc.model.Z2.Z2Builder;
import com.rosetta.test.conditionfunc.model.Z2.Z2BuilderImpl;
import com.rosetta.test.conditionfunc.model.Z2.Z2Impl;
import com.rosetta.test.conditionfunc.model.meta.Z2Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Z2", builder=Z2.Z2BuilderImpl.class, version="test")
public interface Z2 extends RosettaModelObject {
Z2Meta metaData = new Z2Meta();
/*********************** Getter Methods ***********************/
String getStr1Field();
String getStr2Field();
/*********************** Build Methods ***********************/
Z2 build();
Z2.Z2Builder toBuilder();
static Z2.Z2Builder builder() {
return new Z2.Z2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Z2> metaData() {
return metaData;
}
@Override
default Class extends Z2> getType() {
return Z2.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 Z2Builder extends Z2, RosettaModelObjectBuilder {
Z2.Z2Builder setStr1Field(String str1Field);
Z2.Z2Builder 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);
}
Z2.Z2Builder prune();
}
/*********************** Immutable Implementation of Z2 ***********************/
class Z2Impl implements Z2 {
private final String str1Field;
private final String str2Field;
protected Z2Impl(Z2.Z2Builder 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 Z2 build() {
return this;
}
@Override
public Z2.Z2Builder toBuilder() {
Z2.Z2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Z2.Z2Builder 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;
Z2 _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 "Z2 {" +
"str1Field=" + this.str1Field + ", " +
"str2Field=" + this.str2Field +
'}';
}
}
/*********************** Builder Implementation of Z2 ***********************/
class Z2BuilderImpl implements Z2.Z2Builder {
protected String str1Field;
protected String str2Field;
public Z2BuilderImpl() {
}
@Override
@RosettaAttribute("str1Field")
public String getStr1Field() {
return str1Field;
}
@Override
@RosettaAttribute("str2Field")
public String getStr2Field() {
return str2Field;
}
@Override
@RosettaAttribute("str1Field")
public Z2.Z2Builder setStr1Field(String str1Field) {
this.str1Field = str1Field==null?null:str1Field;
return this;
}
@Override
@RosettaAttribute("str2Field")
public Z2.Z2Builder setStr2Field(String str2Field) {
this.str2Field = str2Field==null?null:str2Field;
return this;
}
@Override
public Z2 build() {
return new Z2.Z2Impl(this);
}
@Override
public Z2.Z2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Z2.Z2Builder prune() {
return this;
}
@Override
public boolean hasData() {
if (getStr1Field()!=null) return true;
if (getStr2Field()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Z2.Z2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Z2.Z2Builder o = (Z2.Z2Builder) 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;
Z2 _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 "Z2Builder {" +
"str1Field=" + this.str1Field + ", " +
"str2Field=" + this.str2Field +
'}';
}
}
}