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.TestParty 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.TestParty;
import org.isda.cdm.TestParty.TestPartyBuilder;
import org.isda.cdm.TestParty.TestPartyBuilderImpl;
import org.isda.cdm.TestParty.TestPartyImpl;
import org.isda.cdm.TestPartyIdentifier;
import org.isda.cdm.meta.TestPartyMeta;
import static java.util.Optional.ofNullable;
/**
* The party class.
* @version test
*/
@RosettaDataType(value="TestParty", builder=TestParty.TestPartyBuilderImpl.class, version="test")
public interface TestParty extends RosettaModelObject {
TestPartyMeta metaData = new TestPartyMeta();
/*********************** Getter Methods ***********************/
String getId();
/**
* The set of identifiers associated with a party.
*/
List extends TestPartyIdentifier> getPartyId();
/*********************** Build Methods ***********************/
TestParty build();
TestParty.TestPartyBuilder toBuilder();
static TestParty.TestPartyBuilder builder() {
return new TestParty.TestPartyBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends TestParty> metaData() {
return metaData;
}
@Override
default Class extends TestParty> getType() {
return TestParty.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("id"), String.class, getId(), this);
processRosetta(path.newSubPath("partyId"), processor, TestPartyIdentifier.class, getPartyId());
}
/*********************** Builder Interface ***********************/
interface TestPartyBuilder extends TestParty, RosettaModelObjectBuilder {
TestPartyIdentifier.TestPartyIdentifierBuilder getOrCreatePartyId(int _index);
List extends TestPartyIdentifier.TestPartyIdentifierBuilder> getPartyId();
TestParty.TestPartyBuilder setId(String id);
TestParty.TestPartyBuilder addPartyId(TestPartyIdentifier partyId0);
TestParty.TestPartyBuilder addPartyId(TestPartyIdentifier partyId1, int _idx);
TestParty.TestPartyBuilder addPartyId(List extends TestPartyIdentifier> partyId2);
TestParty.TestPartyBuilder setPartyId(List extends TestPartyIdentifier> partyId3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("id"), String.class, getId(), this);
processRosetta(path.newSubPath("partyId"), processor, TestPartyIdentifier.TestPartyIdentifierBuilder.class, getPartyId());
}
TestParty.TestPartyBuilder prune();
}
/*********************** Immutable Implementation of TestParty ***********************/
class TestPartyImpl implements TestParty {
private final String id;
private final List extends TestPartyIdentifier> partyId;
protected TestPartyImpl(TestParty.TestPartyBuilder builder) {
this.id = builder.getId();
this.partyId = ofNullable(builder.getPartyId()).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("id")
public String getId() {
return id;
}
@Override
@RosettaAttribute("partyId")
public List extends TestPartyIdentifier> getPartyId() {
return partyId;
}
@Override
public TestParty build() {
return this;
}
@Override
public TestParty.TestPartyBuilder toBuilder() {
TestParty.TestPartyBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(TestParty.TestPartyBuilder builder) {
ofNullable(getId()).ifPresent(builder::setId);
ofNullable(getPartyId()).ifPresent(builder::setPartyId);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
TestParty _that = getType().cast(o);
if (!Objects.equals(id, _that.getId())) return false;
if (!ListEquals.listEquals(partyId, _that.getPartyId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (id != null ? id.hashCode() : 0);
_result = 31 * _result + (partyId != null ? partyId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestParty {" +
"id=" + this.id + ", " +
"partyId=" + this.partyId +
'}';
}
}
/*********************** Builder Implementation of TestParty ***********************/
class TestPartyBuilderImpl implements TestParty.TestPartyBuilder {
protected String id;
protected List partyId = new ArrayList<>();
public TestPartyBuilderImpl() {
}
@Override
@RosettaAttribute("id")
public String getId() {
return id;
}
@Override
@RosettaAttribute("partyId")
public List extends TestPartyIdentifier.TestPartyIdentifierBuilder> getPartyId() {
return partyId;
}
public TestPartyIdentifier.TestPartyIdentifierBuilder getOrCreatePartyId(int _index) {
if (partyId==null) {
this.partyId = new ArrayList<>();
}
TestPartyIdentifier.TestPartyIdentifierBuilder result;
return getIndex(partyId, _index, () -> {
TestPartyIdentifier.TestPartyIdentifierBuilder newPartyId = TestPartyIdentifier.builder();
return newPartyId;
});
}
@Override
@RosettaAttribute("id")
public TestParty.TestPartyBuilder setId(String id) {
this.id = id==null?null:id;
return this;
}
@Override
public TestParty.TestPartyBuilder addPartyId(TestPartyIdentifier partyId) {
if (partyId!=null) this.partyId.add(partyId.toBuilder());
return this;
}
@Override
public TestParty.TestPartyBuilder addPartyId(TestPartyIdentifier partyId, int _idx) {
getIndex(this.partyId, _idx, () -> partyId.toBuilder());
return this;
}
@Override
public TestParty.TestPartyBuilder addPartyId(List extends TestPartyIdentifier> partyIds) {
if (partyIds != null) {
for (TestPartyIdentifier toAdd : partyIds) {
this.partyId.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("partyId")
public TestParty.TestPartyBuilder setPartyId(List extends TestPartyIdentifier> partyIds) {
if (partyIds == null) {
this.partyId = new ArrayList<>();
}
else {
this.partyId = partyIds.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public TestParty build() {
return new TestParty.TestPartyImpl(this);
}
@Override
public TestParty.TestPartyBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public TestParty.TestPartyBuilder prune() {
partyId = partyId.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getId()!=null) return true;
if (getPartyId()!=null && getPartyId().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public TestParty.TestPartyBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
TestParty.TestPartyBuilder o = (TestParty.TestPartyBuilder) other;
merger.mergeRosetta(getPartyId(), o.getPartyId(), this::getOrCreatePartyId);
merger.mergeBasic(getId(), o.getId(), this::setId);
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;
TestParty _that = getType().cast(o);
if (!Objects.equals(id, _that.getId())) return false;
if (!ListEquals.listEquals(partyId, _that.getPartyId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (id != null ? id.hashCode() : 0);
_result = 31 * _result + (partyId != null ? partyId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestPartyBuilder {" +
"id=" + this.id + ", " +
"partyId=" + this.partyId +
'}';
}
}
}