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