com.rosetta.testconditional.model.V19_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.V19_3;
import com.rosetta.testconditional.model.V19_3.V19_3Builder;
import com.rosetta.testconditional.model.V19_3.V19_3BuilderImpl;
import com.rosetta.testconditional.model.V19_3.V19_3Impl;
import com.rosetta.testconditional.model.W19_3;
import com.rosetta.testconditional.model.meta.V19_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="V19_3", builder=V19_3.V19_3BuilderImpl.class, version="test")
public interface V19_3 extends RosettaModelObject {
V19_3Meta metaData = new V19_3Meta();
/*********************** Getter Methods ***********************/
List extends W19_3> getWField();
/*********************** Build Methods ***********************/
V19_3 build();
V19_3.V19_3Builder toBuilder();
static V19_3.V19_3Builder builder() {
return new V19_3.V19_3BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends V19_3> metaData() {
return metaData;
}
@Override
default Class extends V19_3> getType() {
return V19_3.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("wField"), processor, W19_3.class, getWField());
}
/*********************** Builder Interface ***********************/
interface V19_3Builder extends V19_3, RosettaModelObjectBuilder {
W19_3.W19_3Builder getOrCreateWField(int _index);
List extends W19_3.W19_3Builder> getWField();
V19_3.V19_3Builder addWField(W19_3 wField0);
V19_3.V19_3Builder addWField(W19_3 wField1, int _idx);
V19_3.V19_3Builder addWField(List extends W19_3> wField2);
V19_3.V19_3Builder setWField(List extends W19_3> wField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("wField"), processor, W19_3.W19_3Builder.class, getWField());
}
V19_3.V19_3Builder prune();
}
/*********************** Immutable Implementation of V19_3 ***********************/
class V19_3Impl implements V19_3 {
private final List extends W19_3> wField;
protected V19_3Impl(V19_3.V19_3Builder builder) {
this.wField = ofNullable(builder.getWField()).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("wField")
public List extends W19_3> getWField() {
return wField;
}
@Override
public V19_3 build() {
return this;
}
@Override
public V19_3.V19_3Builder toBuilder() {
V19_3.V19_3Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(V19_3.V19_3Builder builder) {
ofNullable(getWField()).ifPresent(builder::setWField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
V19_3 _that = getType().cast(o);
if (!ListEquals.listEquals(wField, _that.getWField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (wField != null ? wField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "V19_3 {" +
"wField=" + this.wField +
'}';
}
}
/*********************** Builder Implementation of V19_3 ***********************/
class V19_3BuilderImpl implements V19_3.V19_3Builder {
protected List wField = new ArrayList<>();
public V19_3BuilderImpl() {
}
@Override
@RosettaAttribute("wField")
public List extends W19_3.W19_3Builder> getWField() {
return wField;
}
public W19_3.W19_3Builder getOrCreateWField(int _index) {
if (wField==null) {
this.wField = new ArrayList<>();
}
W19_3.W19_3Builder result;
return getIndex(wField, _index, () -> {
W19_3.W19_3Builder newWField = W19_3.builder();
return newWField;
});
}
@Override
public V19_3.V19_3Builder addWField(W19_3 wField) {
if (wField!=null) this.wField.add(wField.toBuilder());
return this;
}
@Override
public V19_3.V19_3Builder addWField(W19_3 wField, int _idx) {
getIndex(this.wField, _idx, () -> wField.toBuilder());
return this;
}
@Override
public V19_3.V19_3Builder addWField(List extends W19_3> wFields) {
if (wFields != null) {
for (W19_3 toAdd : wFields) {
this.wField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("wField")
public V19_3.V19_3Builder setWField(List extends W19_3> wFields) {
if (wFields == null) {
this.wField = new ArrayList<>();
}
else {
this.wField = wFields.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public V19_3 build() {
return new V19_3.V19_3Impl(this);
}
@Override
public V19_3.V19_3Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public V19_3.V19_3Builder prune() {
wField = wField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getWField()!=null && getWField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public V19_3.V19_3Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
V19_3.V19_3Builder o = (V19_3.V19_3Builder) other;
merger.mergeRosetta(getWField(), o.getWField(), this::getOrCreateWField);
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;
V19_3 _that = getType().cast(o);
if (!ListEquals.listEquals(wField, _that.getWField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (wField != null ? wField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "V19_3Builder {" +
"wField=" + this.wField +
'}';
}
}
}