com.rosetta.testconditional.model.Top27 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.R27;
import com.rosetta.testconditional.model.Top27;
import com.rosetta.testconditional.model.Top27.Top27Builder;
import com.rosetta.testconditional.model.Top27.Top27BuilderImpl;
import com.rosetta.testconditional.model.Top27.Top27Impl;
import com.rosetta.testconditional.model.meta.Top27Meta;
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="Top27", builder=Top27.Top27BuilderImpl.class, version="test")
public interface Top27 extends RosettaModelObject {
Top27Meta metaData = new Top27Meta();
/*********************** Getter Methods ***********************/
List extends R27> getRField();
/*********************** Build Methods ***********************/
Top27 build();
Top27.Top27Builder toBuilder();
static Top27.Top27Builder builder() {
return new Top27.Top27BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top27> metaData() {
return metaData;
}
@Override
default Class extends Top27> getType() {
return Top27.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("rField"), processor, R27.class, getRField());
}
/*********************** Builder Interface ***********************/
interface Top27Builder extends Top27, RosettaModelObjectBuilder {
R27.R27Builder getOrCreateRField(int _index);
List extends R27.R27Builder> getRField();
Top27.Top27Builder addRField(R27 rField0);
Top27.Top27Builder addRField(R27 rField1, int _idx);
Top27.Top27Builder addRField(List extends R27> rField2);
Top27.Top27Builder setRField(List extends R27> rField3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("rField"), processor, R27.R27Builder.class, getRField());
}
Top27.Top27Builder prune();
}
/*********************** Immutable Implementation of Top27 ***********************/
class Top27Impl implements Top27 {
private final List extends R27> rField;
protected Top27Impl(Top27.Top27Builder builder) {
this.rField = ofNullable(builder.getRField()).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("rField")
public List extends R27> getRField() {
return rField;
}
@Override
public Top27 build() {
return this;
}
@Override
public Top27.Top27Builder toBuilder() {
Top27.Top27Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top27.Top27Builder builder) {
ofNullable(getRField()).ifPresent(builder::setRField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top27 _that = getType().cast(o);
if (!ListEquals.listEquals(rField, _that.getRField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (rField != null ? rField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top27 {" +
"rField=" + this.rField +
'}';
}
}
/*********************** Builder Implementation of Top27 ***********************/
class Top27BuilderImpl implements Top27.Top27Builder {
protected List rField = new ArrayList<>();
public Top27BuilderImpl() {
}
@Override
@RosettaAttribute("rField")
public List extends R27.R27Builder> getRField() {
return rField;
}
public R27.R27Builder getOrCreateRField(int _index) {
if (rField==null) {
this.rField = new ArrayList<>();
}
R27.R27Builder result;
return getIndex(rField, _index, () -> {
R27.R27Builder newRField = R27.builder();
return newRField;
});
}
@Override
public Top27.Top27Builder addRField(R27 rField) {
if (rField!=null) this.rField.add(rField.toBuilder());
return this;
}
@Override
public Top27.Top27Builder addRField(R27 rField, int _idx) {
getIndex(this.rField, _idx, () -> rField.toBuilder());
return this;
}
@Override
public Top27.Top27Builder addRField(List extends R27> rFields) {
if (rFields != null) {
for (R27 toAdd : rFields) {
this.rField.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("rField")
public Top27.Top27Builder setRField(List extends R27> rFields) {
if (rFields == null) {
this.rField = new ArrayList<>();
}
else {
this.rField = rFields.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Top27 build() {
return new Top27.Top27Impl(this);
}
@Override
public Top27.Top27Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top27.Top27Builder prune() {
rField = rField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getRField()!=null && getRField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top27.Top27Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top27.Top27Builder o = (Top27.Top27Builder) other;
merger.mergeRosetta(getRField(), o.getRField(), this::getOrCreateRField);
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;
Top27 _that = getType().cast(o);
if (!ListEquals.listEquals(rField, _that.getRField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (rField != null ? rField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top27Builder {" +
"rField=" + this.rField +
'}';
}
}
}