com.rosetta.testconditional.model.Top21_1 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_1;
import com.rosetta.testconditional.model.Top21_1.Top21_1Builder;
import com.rosetta.testconditional.model.Top21_1.Top21_1BuilderImpl;
import com.rosetta.testconditional.model.Top21_1.Top21_1Impl;
import com.rosetta.testconditional.model.V21_1;
import com.rosetta.testconditional.model.meta.Top21_1Meta;
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_1", builder=Top21_1.Top21_1BuilderImpl.class, version="test")
public interface Top21_1 extends RosettaModelObject {
Top21_1Meta metaData = new Top21_1Meta();
/*********************** Getter Methods ***********************/
List extends V21_1> getVField();
/*********************** Build Methods ***********************/
Top21_1 build();
Top21_1.Top21_1Builder toBuilder();
static Top21_1.Top21_1Builder builder() {
return new Top21_1.Top21_1BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top21_1> metaData() {
return metaData;
}
@Override
default Class extends Top21_1> getType() {
return Top21_1.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("vField"), processor, V21_1.class, getVField());
}
/*********************** Builder Interface ***********************/
interface Top21_1Builder extends Top21_1, RosettaModelObjectBuilder {
V21_1.V21_1Builder getOrCreateVField(int _index);
List extends V21_1.V21_1Builder> getVField();
Top21_1.Top21_1Builder addVField(V21_1 vField0);
Top21_1.Top21_1Builder addVField(V21_1 vField1, int _idx);
Top21_1.Top21_1Builder addVField(List extends V21_1> vField2);
Top21_1.Top21_1Builder setVField(List extends V21_1> vField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("vField"), processor, V21_1.V21_1Builder.class, getVField());
}
Top21_1.Top21_1Builder prune();
}
/*********************** Immutable Implementation of Top21_1 ***********************/
class Top21_1Impl implements Top21_1 {
private final List extends V21_1> vField;
protected Top21_1Impl(Top21_1.Top21_1Builder 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_1> getVField() {
return vField;
}
@Override
public Top21_1 build() {
return this;
}
@Override
public Top21_1.Top21_1Builder toBuilder() {
Top21_1.Top21_1Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top21_1.Top21_1Builder 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_1 _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_1 {" +
"vField=" + this.vField +
'}';
}
}
/*********************** Builder Implementation of Top21_1 ***********************/
class Top21_1BuilderImpl implements Top21_1.Top21_1Builder {
protected List vField = new ArrayList<>();
public Top21_1BuilderImpl() {
}
@Override
@RosettaAttribute("vField")
public List extends V21_1.V21_1Builder> getVField() {
return vField;
}
public V21_1.V21_1Builder getOrCreateVField(int _index) {
if (vField==null) {
this.vField = new ArrayList<>();
}
V21_1.V21_1Builder result;
return getIndex(vField, _index, () -> {
V21_1.V21_1Builder newVField = V21_1.builder();
return newVField;
});
}
@Override
public Top21_1.Top21_1Builder addVField(V21_1 vField) {
if (vField!=null) this.vField.add(vField.toBuilder());
return this;
}
@Override
public Top21_1.Top21_1Builder addVField(V21_1 vField, int _idx) {
getIndex(this.vField, _idx, () -> vField.toBuilder());
return this;
}
@Override
public Top21_1.Top21_1Builder addVField(List extends V21_1> vFields) {
if (vFields != null) {
for (V21_1 toAdd : vFields) {
this.vField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("vField")
public Top21_1.Top21_1Builder setVField(List extends V21_1> 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_1 build() {
return new Top21_1.Top21_1Impl(this);
}
@Override
public Top21_1.Top21_1Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top21_1.Top21_1Builder 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_1.Top21_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top21_1.Top21_1Builder o = (Top21_1.Top21_1Builder) 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_1 _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_1Builder {" +
"vField=" + this.vField +
'}';
}
}
}