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