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