com.rosetta.testconditional.model.Top26_4 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_4;
import com.rosetta.testconditional.model.Top26_4.Top26_4Builder;
import com.rosetta.testconditional.model.Top26_4.Top26_4BuilderImpl;
import com.rosetta.testconditional.model.Top26_4.Top26_4Impl;
import com.rosetta.testconditional.model.X26_4;
import com.rosetta.testconditional.model.meta.Top26_4Meta;
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_4", builder=Top26_4.Top26_4BuilderImpl.class, version="test")
public interface Top26_4 extends RosettaModelObject {
Top26_4Meta metaData = new Top26_4Meta();
/*********************** Getter Methods ***********************/
List extends X26_4> getXField();
/*********************** Build Methods ***********************/
Top26_4 build();
Top26_4.Top26_4Builder toBuilder();
static Top26_4.Top26_4Builder builder() {
return new Top26_4.Top26_4BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top26_4> metaData() {
return metaData;
}
@Override
default Class extends Top26_4> getType() {
return Top26_4.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("xField"), processor, X26_4.class, getXField());
}
/*********************** Builder Interface ***********************/
interface Top26_4Builder extends Top26_4, RosettaModelObjectBuilder {
X26_4.X26_4Builder getOrCreateXField(int _index);
List extends X26_4.X26_4Builder> getXField();
Top26_4.Top26_4Builder addXField(X26_4 xField0);
Top26_4.Top26_4Builder addXField(X26_4 xField1, int _idx);
Top26_4.Top26_4Builder addXField(List extends X26_4> xField2);
Top26_4.Top26_4Builder setXField(List extends X26_4> xField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("xField"), processor, X26_4.X26_4Builder.class, getXField());
}
Top26_4.Top26_4Builder prune();
}
/*********************** Immutable Implementation of Top26_4 ***********************/
class Top26_4Impl implements Top26_4 {
private final List extends X26_4> xField;
protected Top26_4Impl(Top26_4.Top26_4Builder 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_4> getXField() {
return xField;
}
@Override
public Top26_4 build() {
return this;
}
@Override
public Top26_4.Top26_4Builder toBuilder() {
Top26_4.Top26_4Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top26_4.Top26_4Builder 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_4 _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_4 {" +
"xField=" + this.xField +
'}';
}
}
/*********************** Builder Implementation of Top26_4 ***********************/
class Top26_4BuilderImpl implements Top26_4.Top26_4Builder {
protected List xField = new ArrayList<>();
public Top26_4BuilderImpl() {
}
@Override
@RosettaAttribute("xField")
public List extends X26_4.X26_4Builder> getXField() {
return xField;
}
public X26_4.X26_4Builder getOrCreateXField(int _index) {
if (xField==null) {
this.xField = new ArrayList<>();
}
X26_4.X26_4Builder result;
return getIndex(xField, _index, () -> {
X26_4.X26_4Builder newXField = X26_4.builder();
return newXField;
});
}
@Override
public Top26_4.Top26_4Builder addXField(X26_4 xField) {
if (xField!=null) this.xField.add(xField.toBuilder());
return this;
}
@Override
public Top26_4.Top26_4Builder addXField(X26_4 xField, int _idx) {
getIndex(this.xField, _idx, () -> xField.toBuilder());
return this;
}
@Override
public Top26_4.Top26_4Builder addXField(List extends X26_4> xFields) {
if (xFields != null) {
for (X26_4 toAdd : xFields) {
this.xField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("xField")
public Top26_4.Top26_4Builder setXField(List extends X26_4> 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_4 build() {
return new Top26_4.Top26_4Impl(this);
}
@Override
public Top26_4.Top26_4Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top26_4.Top26_4Builder 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_4.Top26_4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top26_4.Top26_4Builder o = (Top26_4.Top26_4Builder) 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_4 _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_4Builder {" +
"xField=" + this.xField +
'}';
}
}
}