com.rosetta.metatest.model.PartyTradeIdentifier4 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.metatest.model.PartyTradeIdentifier4;
import com.rosetta.metatest.model.PartyTradeIdentifier4.PartyTradeIdentifier4Builder;
import com.rosetta.metatest.model.PartyTradeIdentifier4.PartyTradeIdentifier4BuilderImpl;
import com.rosetta.metatest.model.PartyTradeIdentifier4.PartyTradeIdentifier4Impl;
import com.rosetta.metatest.model.meta.PartyTradeIdentifier4Meta;
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="PartyTradeIdentifier4", builder=PartyTradeIdentifier4.PartyTradeIdentifier4BuilderImpl.class, version="test")
public interface PartyTradeIdentifier4 extends RosettaModelObject {
PartyTradeIdentifier4Meta metaData = new PartyTradeIdentifier4Meta();
/*********************** Getter Methods ***********************/
List extends FieldWithMetaString> getParty();
/*********************** Build Methods ***********************/
PartyTradeIdentifier4 build();
PartyTradeIdentifier4.PartyTradeIdentifier4Builder toBuilder();
static PartyTradeIdentifier4.PartyTradeIdentifier4Builder builder() {
return new PartyTradeIdentifier4.PartyTradeIdentifier4BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends PartyTradeIdentifier4> metaData() {
return metaData;
}
@Override
default Class extends PartyTradeIdentifier4> getType() {
return PartyTradeIdentifier4.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.class, getParty());
}
/*********************** Builder Interface ***********************/
interface PartyTradeIdentifier4Builder extends PartyTradeIdentifier4, RosettaModelObjectBuilder {
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateParty(int _index);
List extends FieldWithMetaString.FieldWithMetaStringBuilder> getParty();
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(FieldWithMetaString party0);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(FieldWithMetaString party1, int _idx);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(String party2);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(String party3, int _idx);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(List extends FieldWithMetaString> party4);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder setParty(List extends FieldWithMetaString> party5);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(List extends String> party6);
PartyTradeIdentifier4.PartyTradeIdentifier4Builder setPartyValue(List extends String> party7);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getParty());
}
PartyTradeIdentifier4.PartyTradeIdentifier4Builder prune();
}
/*********************** Immutable Implementation of PartyTradeIdentifier4 ***********************/
class PartyTradeIdentifier4Impl implements PartyTradeIdentifier4 {
private final List extends FieldWithMetaString> party;
protected PartyTradeIdentifier4Impl(PartyTradeIdentifier4.PartyTradeIdentifier4Builder 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 PartyTradeIdentifier4 build() {
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder toBuilder() {
PartyTradeIdentifier4.PartyTradeIdentifier4Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(PartyTradeIdentifier4.PartyTradeIdentifier4Builder 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;
PartyTradeIdentifier4 _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 "PartyTradeIdentifier4 {" +
"party=" + this.party +
'}';
}
}
/*********************** Builder Implementation of PartyTradeIdentifier4 ***********************/
class PartyTradeIdentifier4BuilderImpl implements PartyTradeIdentifier4.PartyTradeIdentifier4Builder {
protected List party = new ArrayList<>();
public PartyTradeIdentifier4BuilderImpl() {
}
@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 PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(FieldWithMetaString party) {
if (party!=null) this.party.add(party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(FieldWithMetaString party, int _idx) {
getIndex(this.party, _idx, () -> party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(String party) {
this.getOrCreateParty(-1).setValue(party);
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(String party, int _idx) {
this.getOrCreateParty(_idx).setValue(party);
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder addParty(List extends FieldWithMetaString> partys) {
if (partys != null) {
for (FieldWithMetaString toAdd : partys) {
this.party.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("party")
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder 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 PartyTradeIdentifier4.PartyTradeIdentifier4Builder addPartyValue(List extends String> partys) {
if (partys != null) {
for (String toAdd : partys) {
this.addPartyValue(toAdd);
}
}
return this;
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder setPartyValue(List extends String> partys) {
this.party.clear();
if (partys!=null) {
partys.forEach(this::addPartyValue);
}
return this;
}
@Override
public PartyTradeIdentifier4 build() {
return new PartyTradeIdentifier4.PartyTradeIdentifier4Impl(this);
}
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public PartyTradeIdentifier4.PartyTradeIdentifier4Builder 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 PartyTradeIdentifier4.PartyTradeIdentifier4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
PartyTradeIdentifier4.PartyTradeIdentifier4Builder o = (PartyTradeIdentifier4.PartyTradeIdentifier4Builder) 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;
PartyTradeIdentifier4 _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 "PartyTradeIdentifier4Builder {" +
"party=" + this.party +
'}';
}
}
}