All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.isda.cdm.Middle Maven / Gradle / Ivy
package org.isda.cdm;
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.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.isda.cdm.Flat;
import org.isda.cdm.Middle;
import org.isda.cdm.Middle.MiddleBuilder;
import org.isda.cdm.Middle.MiddleBuilderImpl;
import org.isda.cdm.Middle.MiddleImpl;
import org.isda.cdm.meta.MiddleMeta;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Middle", builder=Middle.MiddleBuilderImpl.class, version="test")
public interface Middle extends RosettaModelObject {
MiddleMeta metaData = new MiddleMeta();
/*********************** Getter Methods ***********************/
List extends Flat> getFieldWithNoSynonym();
List extends Middle> getMiddle();
/*********************** Build Methods ***********************/
Middle build();
Middle.MiddleBuilder toBuilder();
static Middle.MiddleBuilder builder() {
return new Middle.MiddleBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Middle> metaData() {
return metaData;
}
@Override
default Class extends Middle> getType() {
return Middle.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("fieldWithNoSynonym"), processor, Flat.class, getFieldWithNoSynonym());
processRosetta(path.newSubPath("middle"), processor, Middle.class, getMiddle());
}
/*********************** Builder Interface ***********************/
interface MiddleBuilder extends Middle, RosettaModelObjectBuilder {
Flat.FlatBuilder getOrCreateFieldWithNoSynonym(int _index);
List extends Flat.FlatBuilder> getFieldWithNoSynonym();
Middle.MiddleBuilder getOrCreateMiddle(int _index);
List extends Middle.MiddleBuilder> getMiddle();
Middle.MiddleBuilder addFieldWithNoSynonym(Flat fieldWithNoSynonym0);
Middle.MiddleBuilder addFieldWithNoSynonym(Flat fieldWithNoSynonym1, int _idx);
Middle.MiddleBuilder addFieldWithNoSynonym(List extends Flat> fieldWithNoSynonym2);
Middle.MiddleBuilder setFieldWithNoSynonym(List extends Flat> fieldWithNoSynonym3);
Middle.MiddleBuilder addMiddle(Middle middle0);
Middle.MiddleBuilder addMiddle(Middle middle1, int _idx);
Middle.MiddleBuilder addMiddle(List extends Middle> middle2);
Middle.MiddleBuilder setMiddle(List extends Middle> middle3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("fieldWithNoSynonym"), processor, Flat.FlatBuilder.class, getFieldWithNoSynonym());
processRosetta(path.newSubPath("middle"), processor, Middle.MiddleBuilder.class, getMiddle());
}
Middle.MiddleBuilder prune();
}
/*********************** Immutable Implementation of Middle ***********************/
class MiddleImpl implements Middle {
private final List extends Flat> fieldWithNoSynonym;
private final List extends Middle> middle;
protected MiddleImpl(Middle.MiddleBuilder builder) {
this.fieldWithNoSynonym = ofNullable(builder.getFieldWithNoSynonym()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
this.middle = ofNullable(builder.getMiddle()).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("fieldWithNoSynonym")
public List extends Flat> getFieldWithNoSynonym() {
return fieldWithNoSynonym;
}
@Override
@RosettaAttribute("middle")
public List extends Middle> getMiddle() {
return middle;
}
@Override
public Middle build() {
return this;
}
@Override
public Middle.MiddleBuilder toBuilder() {
Middle.MiddleBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Middle.MiddleBuilder builder) {
ofNullable(getFieldWithNoSynonym()).ifPresent(builder::setFieldWithNoSynonym);
ofNullable(getMiddle()).ifPresent(builder::setMiddle);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Middle _that = getType().cast(o);
if (!ListEquals.listEquals(fieldWithNoSynonym, _that.getFieldWithNoSynonym())) return false;
if (!ListEquals.listEquals(middle, _that.getMiddle())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (fieldWithNoSynonym != null ? fieldWithNoSynonym.hashCode() : 0);
_result = 31 * _result + (middle != null ? middle.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Middle {" +
"fieldWithNoSynonym=" + this.fieldWithNoSynonym + ", " +
"middle=" + this.middle +
'}';
}
}
/*********************** Builder Implementation of Middle ***********************/
class MiddleBuilderImpl implements Middle.MiddleBuilder {
protected List fieldWithNoSynonym = new ArrayList<>();
protected List middle = new ArrayList<>();
public MiddleBuilderImpl() {
}
@Override
@RosettaAttribute("fieldWithNoSynonym")
public List extends Flat.FlatBuilder> getFieldWithNoSynonym() {
return fieldWithNoSynonym;
}
public Flat.FlatBuilder getOrCreateFieldWithNoSynonym(int _index) {
if (fieldWithNoSynonym==null) {
this.fieldWithNoSynonym = new ArrayList<>();
}
Flat.FlatBuilder result;
return getIndex(fieldWithNoSynonym, _index, () -> {
Flat.FlatBuilder newFieldWithNoSynonym = Flat.builder();
return newFieldWithNoSynonym;
});
}
@Override
@RosettaAttribute("middle")
public List extends Middle.MiddleBuilder> getMiddle() {
return middle;
}
public Middle.MiddleBuilder getOrCreateMiddle(int _index) {
if (middle==null) {
this.middle = new ArrayList<>();
}
Middle.MiddleBuilder result;
return getIndex(middle, _index, () -> {
Middle.MiddleBuilder newMiddle = Middle.builder();
return newMiddle;
});
}
@Override
public Middle.MiddleBuilder addFieldWithNoSynonym(Flat fieldWithNoSynonym) {
if (fieldWithNoSynonym!=null) this.fieldWithNoSynonym.add(fieldWithNoSynonym.toBuilder());
return this;
}
@Override
public Middle.MiddleBuilder addFieldWithNoSynonym(Flat fieldWithNoSynonym, int _idx) {
getIndex(this.fieldWithNoSynonym, _idx, () -> fieldWithNoSynonym.toBuilder());
return this;
}
@Override
public Middle.MiddleBuilder addFieldWithNoSynonym(List extends Flat> fieldWithNoSynonyms) {
if (fieldWithNoSynonyms != null) {
for (Flat toAdd : fieldWithNoSynonyms) {
this.fieldWithNoSynonym.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("fieldWithNoSynonym")
public Middle.MiddleBuilder setFieldWithNoSynonym(List extends Flat> fieldWithNoSynonyms) {
if (fieldWithNoSynonyms == null) {
this.fieldWithNoSynonym = new ArrayList<>();
}
else {
this.fieldWithNoSynonym = fieldWithNoSynonyms.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Middle.MiddleBuilder addMiddle(Middle middle) {
if (middle!=null) this.middle.add(middle.toBuilder());
return this;
}
@Override
public Middle.MiddleBuilder addMiddle(Middle middle, int _idx) {
getIndex(this.middle, _idx, () -> middle.toBuilder());
return this;
}
@Override
public Middle.MiddleBuilder addMiddle(List extends Middle> middles) {
if (middles != null) {
for (Middle toAdd : middles) {
this.middle.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("middle")
public Middle.MiddleBuilder setMiddle(List extends Middle> middles) {
if (middles == null) {
this.middle = new ArrayList<>();
}
else {
this.middle = middles.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Middle build() {
return new Middle.MiddleImpl(this);
}
@Override
public Middle.MiddleBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Middle.MiddleBuilder prune() {
fieldWithNoSynonym = fieldWithNoSynonym.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
middle = middle.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getFieldWithNoSynonym()!=null && getFieldWithNoSynonym().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
if (getMiddle()!=null && getMiddle().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Middle.MiddleBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Middle.MiddleBuilder o = (Middle.MiddleBuilder) other;
merger.mergeRosetta(getFieldWithNoSynonym(), o.getFieldWithNoSynonym(), this::getOrCreateFieldWithNoSynonym);
merger.mergeRosetta(getMiddle(), o.getMiddle(), this::getOrCreateMiddle);
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;
Middle _that = getType().cast(o);
if (!ListEquals.listEquals(fieldWithNoSynonym, _that.getFieldWithNoSynonym())) return false;
if (!ListEquals.listEquals(middle, _that.getMiddle())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (fieldWithNoSynonym != null ? fieldWithNoSynonym.hashCode() : 0);
_result = 31 * _result + (middle != null ? middle.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "MiddleBuilder {" +
"fieldWithNoSynonym=" + this.fieldWithNoSynonym + ", " +
"middle=" + this.middle +
'}';
}
}
}