com.rosetta.testconditional.model.Top21_2 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.Top21_2;
import com.rosetta.testconditional.model.Top21_2.Top21_2Builder;
import com.rosetta.testconditional.model.Top21_2.Top21_2BuilderImpl;
import com.rosetta.testconditional.model.Top21_2.Top21_2Impl;
import com.rosetta.testconditional.model.V21_2;
import com.rosetta.testconditional.model.meta.Top21_2Meta;
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="Top21_2", builder=Top21_2.Top21_2BuilderImpl.class, version="test")
public interface Top21_2 extends RosettaModelObject {
Top21_2Meta metaData = new Top21_2Meta();
/*********************** Getter Methods ***********************/
List extends V21_2> getVField();
/*********************** Build Methods ***********************/
Top21_2 build();
Top21_2.Top21_2Builder toBuilder();
static Top21_2.Top21_2Builder builder() {
return new Top21_2.Top21_2BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top21_2> metaData() {
return metaData;
}
@Override
default Class extends Top21_2> getType() {
return Top21_2.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("vField"), processor, V21_2.class, getVField());
}
/*********************** Builder Interface ***********************/
interface Top21_2Builder extends Top21_2, RosettaModelObjectBuilder {
V21_2.V21_2Builder getOrCreateVField(int _index);
List extends V21_2.V21_2Builder> getVField();
Top21_2.Top21_2Builder addVField(V21_2 vField0);
Top21_2.Top21_2Builder addVField(V21_2 vField1, int _idx);
Top21_2.Top21_2Builder addVField(List extends V21_2> vField2);
Top21_2.Top21_2Builder setVField(List extends V21_2> vField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("vField"), processor, V21_2.V21_2Builder.class, getVField());
}
Top21_2.Top21_2Builder prune();
}
/*********************** Immutable Implementation of Top21_2 ***********************/
class Top21_2Impl implements Top21_2 {
private final List extends V21_2> vField;
protected Top21_2Impl(Top21_2.Top21_2Builder builder) {
this.vField = ofNullable(builder.getVField()).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("vField")
public List extends V21_2> getVField() {
return vField;
}
@Override
public Top21_2 build() {
return this;
}
@Override
public Top21_2.Top21_2Builder toBuilder() {
Top21_2.Top21_2Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top21_2.Top21_2Builder builder) {
ofNullable(getVField()).ifPresent(builder::setVField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top21_2 _that = getType().cast(o);
if (!ListEquals.listEquals(vField, _that.getVField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (vField != null ? vField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top21_2 {" +
"vField=" + this.vField +
'}';
}
}
/*********************** Builder Implementation of Top21_2 ***********************/
class Top21_2BuilderImpl implements Top21_2.Top21_2Builder {
protected List vField = new ArrayList<>();
public Top21_2BuilderImpl() {
}
@Override
@RosettaAttribute("vField")
public List extends V21_2.V21_2Builder> getVField() {
return vField;
}
public V21_2.V21_2Builder getOrCreateVField(int _index) {
if (vField==null) {
this.vField = new ArrayList<>();
}
V21_2.V21_2Builder result;
return getIndex(vField, _index, () -> {
V21_2.V21_2Builder newVField = V21_2.builder();
return newVField;
});
}
@Override
public Top21_2.Top21_2Builder addVField(V21_2 vField) {
if (vField!=null) this.vField.add(vField.toBuilder());
return this;
}
@Override
public Top21_2.Top21_2Builder addVField(V21_2 vField, int _idx) {
getIndex(this.vField, _idx, () -> vField.toBuilder());
return this;
}
@Override
public Top21_2.Top21_2Builder addVField(List extends V21_2> vFields) {
if (vFields != null) {
for (V21_2 toAdd : vFields) {
this.vField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("vField")
public Top21_2.Top21_2Builder setVField(List extends V21_2> vFields) {
if (vFields == null) {
this.vField = new ArrayList<>();
}
else {
this.vField = vFields.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Top21_2 build() {
return new Top21_2.Top21_2Impl(this);
}
@Override
public Top21_2.Top21_2Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top21_2.Top21_2Builder prune() {
vField = vField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getVField()!=null && getVField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top21_2.Top21_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top21_2.Top21_2Builder o = (Top21_2.Top21_2Builder) other;
merger.mergeRosetta(getVField(), o.getVField(), this::getOrCreateVField);
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;
Top21_2 _that = getType().cast(o);
if (!ListEquals.listEquals(vField, _that.getVField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (vField != null ? vField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top21_2Builder {" +
"vField=" + this.vField +
'}';
}
}
}