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