com.rosetta.testconditional.model.Top26_3 Maven / Gradle / Ivy
package com.rosetta.testconditional.model;
import com.google.common.collect.ImmutableList;
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.testconditional.model.Top26_3;
import com.rosetta.testconditional.model.Top26_3.Top26_3Builder;
import com.rosetta.testconditional.model.Top26_3.Top26_3BuilderImpl;
import com.rosetta.testconditional.model.Top26_3.Top26_3Impl;
import com.rosetta.testconditional.model.X26_3;
import com.rosetta.testconditional.model.meta.Top26_3Meta;
import com.rosetta.util.ListEquals;
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="Top26_3", builder=Top26_3.Top26_3BuilderImpl.class, version="test")
public interface Top26_3 extends RosettaModelObject {
Top26_3Meta metaData = new Top26_3Meta();
/*********************** Getter Methods ***********************/
List extends X26_3> getXField();
/*********************** Build Methods ***********************/
Top26_3 build();
Top26_3.Top26_3Builder toBuilder();
static Top26_3.Top26_3Builder builder() {
return new Top26_3.Top26_3BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top26_3> metaData() {
return metaData;
}
@Override
default Class extends Top26_3> getType() {
return Top26_3.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("xField"), processor, X26_3.class, getXField());
}
/*********************** Builder Interface ***********************/
interface Top26_3Builder extends Top26_3, RosettaModelObjectBuilder {
X26_3.X26_3Builder getOrCreateXField(int _index);
List extends X26_3.X26_3Builder> getXField();
Top26_3.Top26_3Builder addXField(X26_3 xField0);
Top26_3.Top26_3Builder addXField(X26_3 xField1, int _idx);
Top26_3.Top26_3Builder addXField(List extends X26_3> xField2);
Top26_3.Top26_3Builder setXField(List extends X26_3> xField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("xField"), processor, X26_3.X26_3Builder.class, getXField());
}
Top26_3.Top26_3Builder prune();
}
/*********************** Immutable Implementation of Top26_3 ***********************/
class Top26_3Impl implements Top26_3 {
private final List extends X26_3> xField;
protected Top26_3Impl(Top26_3.Top26_3Builder builder) {
this.xField = ofNullable(builder.getXField()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
}
@Override
@RosettaAttribute("xField")
public List extends X26_3> getXField() {
return xField;
}
@Override
public Top26_3 build() {
return this;
}
@Override
public Top26_3.Top26_3Builder toBuilder() {
Top26_3.Top26_3Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top26_3.Top26_3Builder builder) {
ofNullable(getXField()).ifPresent(builder::setXField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top26_3 _that = getType().cast(o);
if (!ListEquals.listEquals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top26_3 {" +
"xField=" + this.xField +
'}';
}
}
/*********************** Builder Implementation of Top26_3 ***********************/
class Top26_3BuilderImpl implements Top26_3.Top26_3Builder {
protected List xField = new ArrayList<>();
public Top26_3BuilderImpl() {
}
@Override
@RosettaAttribute("xField")
public List extends X26_3.X26_3Builder> getXField() {
return xField;
}
public X26_3.X26_3Builder getOrCreateXField(int _index) {
if (xField==null) {
this.xField = new ArrayList<>();
}
X26_3.X26_3Builder result;
return getIndex(xField, _index, () -> {
X26_3.X26_3Builder newXField = X26_3.builder();
return newXField;
});
}
@Override
public Top26_3.Top26_3Builder addXField(X26_3 xField) {
if (xField!=null) this.xField.add(xField.toBuilder());
return this;
}
@Override
public Top26_3.Top26_3Builder addXField(X26_3 xField, int _idx) {
getIndex(this.xField, _idx, () -> xField.toBuilder());
return this;
}
@Override
public Top26_3.Top26_3Builder addXField(List extends X26_3> xFields) {
if (xFields != null) {
for (X26_3 toAdd : xFields) {
this.xField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("xField")
public Top26_3.Top26_3Builder setXField(List extends X26_3> xFields) {
if (xFields == null) {
this.xField = new ArrayList<>();
}
else {
this.xField = xFields.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Top26_3 build() {
return new Top26_3.Top26_3Impl(this);
}
@Override
public Top26_3.Top26_3Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top26_3.Top26_3Builder prune() {
xField = xField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getXField()!=null && getXField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top26_3.Top26_3Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top26_3.Top26_3Builder o = (Top26_3.Top26_3Builder) other;
merger.mergeRosetta(getXField(), o.getXField(), this::getOrCreateXField);
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;
Top26_3 _that = getType().cast(o);
if (!ListEquals.listEquals(xField, _that.getXField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top26_3Builder {" +
"xField=" + this.xField +
'}';
}
}
}