com.rosetta.testother.model.Top8 Maven / Gradle / Ivy
package com.rosetta.testother.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.testother.model.A8_1;
import com.rosetta.testother.model.Top8;
import com.rosetta.testother.model.Top8.Top8Builder;
import com.rosetta.testother.model.Top8.Top8BuilderImpl;
import com.rosetta.testother.model.Top8.Top8Impl;
import com.rosetta.testother.model.Top8Super;
import com.rosetta.testother.model.Top8Super.Top8SuperBuilder;
import com.rosetta.testother.model.Top8Super.Top8SuperBuilderImpl;
import com.rosetta.testother.model.Top8Super.Top8SuperImpl;
import com.rosetta.testother.model.meta.Top8Meta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Top8", builder=Top8.Top8BuilderImpl.class, version="test")
public interface Top8 extends Top8Super {
Top8Meta metaData = new Top8Meta();
/*********************** Getter Methods ***********************/
String getDummy();
/*********************** Build Methods ***********************/
Top8 build();
Top8.Top8Builder toBuilder();
static Top8.Top8Builder builder() {
return new Top8.Top8BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top8> metaData() {
return metaData;
}
@Override
default Class extends Top8> getType() {
return Top8.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("a1Field"), processor, A8_1.class, getA1Field());
processor.processBasic(path.newSubPath("dummy"), String.class, getDummy(), this);
}
/*********************** Builder Interface ***********************/
interface Top8Builder extends Top8, Top8Super.Top8SuperBuilder {
Top8.Top8Builder addA1Field(A8_1 a1Field0);
Top8.Top8Builder addA1Field(A8_1 a1Field1, int _idx);
Top8.Top8Builder addA1Field(List extends A8_1> a1Field2);
Top8.Top8Builder setA1Field(List extends A8_1> a1Field3);
Top8.Top8Builder setDummy(String dummy);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("a1Field"), processor, A8_1.A8_1Builder.class, getA1Field());
processor.processBasic(path.newSubPath("dummy"), String.class, getDummy(), this);
}
Top8.Top8Builder prune();
}
/*********************** Immutable Implementation of Top8 ***********************/
class Top8Impl extends Top8Super.Top8SuperImpl implements Top8 {
private final String dummy;
protected Top8Impl(Top8.Top8Builder builder) {
super(builder);
this.dummy = builder.getDummy();
}
@Override
@RosettaAttribute("dummy")
public String getDummy() {
return dummy;
}
@Override
public Top8 build() {
return this;
}
@Override
public Top8.Top8Builder toBuilder() {
Top8.Top8Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top8.Top8Builder builder) {
super.setBuilderFields(builder);
ofNullable(getDummy()).ifPresent(builder::setDummy);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
if (!super.equals(o)) return false;
Top8 _that = getType().cast(o);
if (!Objects.equals(dummy, _that.getDummy())) return false;
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (dummy != null ? dummy.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top8 {" +
"dummy=" + this.dummy +
'}' + " " + super.toString();
}
}
/*********************** Builder Implementation of Top8 ***********************/
class Top8BuilderImpl extends Top8Super.Top8SuperBuilderImpl implements Top8.Top8Builder {
protected String dummy;
public Top8BuilderImpl() {
}
@Override
@RosettaAttribute("dummy")
public String getDummy() {
return dummy;
}
@Override
public Top8.Top8Builder addA1Field(A8_1 a1Field) {
if (a1Field!=null) this.a1Field.add(a1Field.toBuilder());
return this;
}
@Override
public Top8.Top8Builder addA1Field(A8_1 a1Field, int _idx) {
getIndex(this.a1Field, _idx, () -> a1Field.toBuilder());
return this;
}
@Override
public Top8.Top8Builder addA1Field(List extends A8_1> a1Fields) {
if (a1Fields != null) {
for (A8_1 toAdd : a1Fields) {
this.a1Field.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("a1Field")
public Top8.Top8Builder setA1Field(List extends A8_1> a1Fields) {
if (a1Fields == null) {
this.a1Field = new ArrayList<>();
}
else {
this.a1Field = a1Fields.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
@RosettaAttribute("dummy")
public Top8.Top8Builder setDummy(String dummy) {
this.dummy = dummy==null?null:dummy;
return this;
}
@Override
public Top8 build() {
return new Top8.Top8Impl(this);
}
@Override
public Top8.Top8Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top8.Top8Builder prune() {
super.prune();
return this;
}
@Override
public boolean hasData() {
if (super.hasData()) return true;
if (getDummy()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top8.Top8Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
super.merge(other, merger);
Top8.Top8Builder o = (Top8.Top8Builder) other;
merger.mergeBasic(getDummy(), o.getDummy(), this::setDummy);
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;
if (!super.equals(o)) return false;
Top8 _that = getType().cast(o);
if (!Objects.equals(dummy, _that.getDummy())) return false;
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (dummy != null ? dummy.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top8Builder {" +
"dummy=" + this.dummy +
'}' + " " + super.toString();
}
}
}