org.isda.cdm.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 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.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1;
import org.isda.cdm.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder;
import org.isda.cdm.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1BuilderImpl;
import org.isda.cdm.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Impl;
import org.isda.cdm.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2;
import org.isda.cdm.meta.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Meta;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1", builder=ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1BuilderImpl.class, version="test")
public interface ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 extends RosettaModelObject {
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Meta metaData = new ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Meta();
/*********************** Getter Methods ***********************/
List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> getWithoutSynonym();
/*********************** Build Methods ***********************/
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 build();
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder toBuilder();
static ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder builder() {
return new ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1> metaData() {
return metaData;
}
@Override
default Class extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1> getType() {
return ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("withoutSynonym"), processor, ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.class, getWithoutSynonym());
}
/*********************** Builder Interface ***********************/
interface ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1, RosettaModelObjectBuilder {
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder getOrCreateWithoutSynonym(int _index);
List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder> getWithoutSynonym();
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2 withoutSynonym0);
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2 withoutSynonym1, int _idx);
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> withoutSynonym2);
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder setWithoutSynonym(List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> withoutSynonym3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("withoutSynonym"), processor, ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder.class, getWithoutSynonym());
}
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder prune();
}
/*********************** Immutable Implementation of ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 ***********************/
class ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Impl implements ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 {
private final List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> withoutSynonym;
protected ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Impl(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder builder) {
this.withoutSynonym = ofNullable(builder.getWithoutSynonym()).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("withoutSynonym")
public List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> getWithoutSynonym() {
return withoutSynonym;
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 build() {
return this;
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder toBuilder() {
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder builder) {
ofNullable(getWithoutSynonym()).ifPresent(builder::setWithoutSynonym);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 _that = getType().cast(o);
if (!ListEquals.listEquals(withoutSynonym, _that.getWithoutSynonym())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (withoutSynonym != null ? withoutSynonym.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 {" +
"withoutSynonym=" + this.withoutSynonym +
'}';
}
}
/*********************** Builder Implementation of ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 ***********************/
class ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1BuilderImpl implements ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder {
protected List withoutSynonym = new ArrayList<>();
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1BuilderImpl() {
}
@Override
@RosettaAttribute("withoutSynonym")
public List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder> getWithoutSynonym() {
return withoutSynonym;
}
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder getOrCreateWithoutSynonym(int _index) {
if (withoutSynonym==null) {
this.withoutSynonym = new ArrayList<>();
}
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder result;
return getIndex(withoutSynonym, _index, () -> {
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2Builder newWithoutSynonym = ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2.builder();
return newWithoutSynonym;
});
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2 withoutSynonym) {
if (withoutSynonym!=null) this.withoutSynonym.add(withoutSynonym.toBuilder());
return this;
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2 withoutSynonym, int _idx) {
getIndex(this.withoutSynonym, _idx, () -> withoutSynonym.toBuilder());
return this;
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder addWithoutSynonym(List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> withoutSynonyms) {
if (withoutSynonyms != null) {
for (ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2 toAdd : withoutSynonyms) {
this.withoutSynonym.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("withoutSynonym")
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder setWithoutSynonym(List extends ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_2> withoutSynonyms) {
if (withoutSynonyms == null) {
this.withoutSynonym = new ArrayList<>();
}
else {
this.withoutSynonym = withoutSynonyms.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 build() {
return new ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Impl(this);
}
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder prune() {
withoutSynonym = withoutSynonym.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getWithoutSynonym()!=null && getWithoutSynonym().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder o = (ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1.ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder) other;
merger.mergeRosetta(getWithoutSynonym(), o.getWithoutSynonym(), this::getOrCreateWithoutSynonym);
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;
ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1 _that = getType().cast(o);
if (!ListEquals.listEquals(withoutSynonym, _that.getWithoutSynonym())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (withoutSynonym != null ? withoutSynonym.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ShouldUseLongestSynonymPathWhenMultipleSynonymsMatch_1Builder {" +
"withoutSynonym=" + this.withoutSynonym +
'}';
}
}
}