com.rosetta.externalsynonym.model.PartyTradeIdentifier1 Maven / Gradle / Ivy
package com.rosetta.externalsynonym.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.externalsynonym.model.PartyTradeIdentifier1;
import com.rosetta.externalsynonym.model.PartyTradeIdentifier1.PartyTradeIdentifier1Builder;
import com.rosetta.externalsynonym.model.PartyTradeIdentifier1.PartyTradeIdentifier1BuilderImpl;
import com.rosetta.externalsynonym.model.PartyTradeIdentifier1.PartyTradeIdentifier1Impl;
import com.rosetta.externalsynonym.model.meta.PartyTradeIdentifier1Meta;
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.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
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="PartyTradeIdentifier1", builder=PartyTradeIdentifier1.PartyTradeIdentifier1BuilderImpl.class, version="test")
public interface PartyTradeIdentifier1 extends RosettaModelObject {
PartyTradeIdentifier1Meta metaData = new PartyTradeIdentifier1Meta();
/*********************** Getter Methods ***********************/
List extends FieldWithMetaString> getParty();
/*********************** Build Methods ***********************/
PartyTradeIdentifier1 build();
PartyTradeIdentifier1.PartyTradeIdentifier1Builder toBuilder();
static PartyTradeIdentifier1.PartyTradeIdentifier1Builder builder() {
return new PartyTradeIdentifier1.PartyTradeIdentifier1BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends PartyTradeIdentifier1> metaData() {
return metaData;
}
@Override
default Class extends PartyTradeIdentifier1> getType() {
return PartyTradeIdentifier1.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.class, getParty());
}
/*********************** Builder Interface ***********************/
interface PartyTradeIdentifier1Builder extends PartyTradeIdentifier1, RosettaModelObjectBuilder {
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateParty(int _index);
List extends FieldWithMetaString.FieldWithMetaStringBuilder> getParty();
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(FieldWithMetaString party0);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(FieldWithMetaString party1, int _idx);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(String party2);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(String party3, int _idx);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(List extends FieldWithMetaString> party4);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder setParty(List extends FieldWithMetaString> party5);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(List extends String> party6);
PartyTradeIdentifier1.PartyTradeIdentifier1Builder setPartyValue(List extends String> party7);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getParty());
}
PartyTradeIdentifier1.PartyTradeIdentifier1Builder prune();
}
/*********************** Immutable Implementation of PartyTradeIdentifier1 ***********************/
class PartyTradeIdentifier1Impl implements PartyTradeIdentifier1 {
private final List extends FieldWithMetaString> party;
protected PartyTradeIdentifier1Impl(PartyTradeIdentifier1.PartyTradeIdentifier1Builder builder) {
this.party = ofNullable(builder.getParty()).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("party")
public List extends FieldWithMetaString> getParty() {
return party;
}
@Override
public PartyTradeIdentifier1 build() {
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder toBuilder() {
PartyTradeIdentifier1.PartyTradeIdentifier1Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(PartyTradeIdentifier1.PartyTradeIdentifier1Builder builder) {
ofNullable(getParty()).ifPresent(builder::setParty);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
PartyTradeIdentifier1 _that = getType().cast(o);
if (!ListEquals.listEquals(party, _that.getParty())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (party != null ? party.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PartyTradeIdentifier1 {" +
"party=" + this.party +
'}';
}
}
/*********************** Builder Implementation of PartyTradeIdentifier1 ***********************/
class PartyTradeIdentifier1BuilderImpl implements PartyTradeIdentifier1.PartyTradeIdentifier1Builder {
protected List party = new ArrayList<>();
public PartyTradeIdentifier1BuilderImpl() {
}
@Override
@RosettaAttribute("party")
public List extends FieldWithMetaString.FieldWithMetaStringBuilder> getParty() {
return party;
}
public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateParty(int _index) {
if (party==null) {
this.party = new ArrayList<>();
}
FieldWithMetaString.FieldWithMetaStringBuilder result;
return getIndex(party, _index, () -> {
FieldWithMetaString.FieldWithMetaStringBuilder newParty = FieldWithMetaString.builder();
return newParty;
});
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(FieldWithMetaString party) {
if (party!=null) this.party.add(party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(FieldWithMetaString party, int _idx) {
getIndex(this.party, _idx, () -> party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(String party) {
this.getOrCreateParty(-1).setValue(party);
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(String party, int _idx) {
this.getOrCreateParty(_idx).setValue(party);
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addParty(List extends FieldWithMetaString> partys) {
if (partys != null) {
for (FieldWithMetaString toAdd : partys) {
this.party.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("party")
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder setParty(List extends FieldWithMetaString> partys) {
if (partys == null) {
this.party = new ArrayList<>();
}
else {
this.party = partys.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(List extends String> partys) {
if (partys != null) {
for (String toAdd : partys) {
this.addPartyValue(toAdd);
}
}
return this;
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder setPartyValue(List extends String> partys) {
this.party.clear();
if (partys!=null) {
partys.forEach(this::addPartyValue);
}
return this;
}
@Override
public PartyTradeIdentifier1 build() {
return new PartyTradeIdentifier1.PartyTradeIdentifier1Impl(this);
}
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder prune() {
party = party.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getParty()!=null && !getParty().isEmpty()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public PartyTradeIdentifier1.PartyTradeIdentifier1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
PartyTradeIdentifier1.PartyTradeIdentifier1Builder o = (PartyTradeIdentifier1.PartyTradeIdentifier1Builder) other;
merger.mergeRosetta(getParty(), o.getParty(), this::getOrCreateParty);
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;
PartyTradeIdentifier1 _that = getType().cast(o);
if (!ListEquals.listEquals(party, _that.getParty())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (party != null ? party.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PartyTradeIdentifier1Builder {" +
"party=" + this.party +
'}';
}
}
}