com.rosetta.testcard.model.PartyTradeIdentifier9 Maven / Gradle / Ivy
package com.rosetta.testcard.model;
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.testcard.model.FieldWithMeta9;
import com.rosetta.testcard.model.PartyTradeIdentifier9;
import com.rosetta.testcard.model.PartyTradeIdentifier9.PartyTradeIdentifier9Builder;
import com.rosetta.testcard.model.PartyTradeIdentifier9.PartyTradeIdentifier9BuilderImpl;
import com.rosetta.testcard.model.PartyTradeIdentifier9.PartyTradeIdentifier9Impl;
import com.rosetta.testcard.model.meta.PartyTradeIdentifier9Meta;
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="PartyTradeIdentifier9", builder=PartyTradeIdentifier9.PartyTradeIdentifier9BuilderImpl.class, version="test")
public interface PartyTradeIdentifier9 extends RosettaModelObject {
PartyTradeIdentifier9Meta metaData = new PartyTradeIdentifier9Meta();
/*********************** Getter Methods ***********************/
List extends FieldWithMeta9> getParty();
/*********************** Build Methods ***********************/
PartyTradeIdentifier9 build();
PartyTradeIdentifier9.PartyTradeIdentifier9Builder toBuilder();
static PartyTradeIdentifier9.PartyTradeIdentifier9Builder builder() {
return new PartyTradeIdentifier9.PartyTradeIdentifier9BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends PartyTradeIdentifier9> metaData() {
return metaData;
}
@Override
default Class extends PartyTradeIdentifier9> getType() {
return PartyTradeIdentifier9.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMeta9.class, getParty());
}
/*********************** Builder Interface ***********************/
interface PartyTradeIdentifier9Builder extends PartyTradeIdentifier9, RosettaModelObjectBuilder {
FieldWithMeta9.FieldWithMeta9Builder getOrCreateParty(int _index);
List extends FieldWithMeta9.FieldWithMeta9Builder> getParty();
PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(FieldWithMeta9 party0);
PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(FieldWithMeta9 party1, int _idx);
PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(List extends FieldWithMeta9> party2);
PartyTradeIdentifier9.PartyTradeIdentifier9Builder setParty(List extends FieldWithMeta9> party3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("party"), processor, FieldWithMeta9.FieldWithMeta9Builder.class, getParty());
}
PartyTradeIdentifier9.PartyTradeIdentifier9Builder prune();
}
/*********************** Immutable Implementation of PartyTradeIdentifier9 ***********************/
class PartyTradeIdentifier9Impl implements PartyTradeIdentifier9 {
private final List extends FieldWithMeta9> party;
protected PartyTradeIdentifier9Impl(PartyTradeIdentifier9.PartyTradeIdentifier9Builder 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 FieldWithMeta9> getParty() {
return party;
}
@Override
public PartyTradeIdentifier9 build() {
return this;
}
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder toBuilder() {
PartyTradeIdentifier9.PartyTradeIdentifier9Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(PartyTradeIdentifier9.PartyTradeIdentifier9Builder 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;
PartyTradeIdentifier9 _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 "PartyTradeIdentifier9 {" +
"party=" + this.party +
'}';
}
}
/*********************** Builder Implementation of PartyTradeIdentifier9 ***********************/
class PartyTradeIdentifier9BuilderImpl implements PartyTradeIdentifier9.PartyTradeIdentifier9Builder {
protected List party = new ArrayList<>();
public PartyTradeIdentifier9BuilderImpl() {
}
@Override
@RosettaAttribute("party")
public List extends FieldWithMeta9.FieldWithMeta9Builder> getParty() {
return party;
}
public FieldWithMeta9.FieldWithMeta9Builder getOrCreateParty(int _index) {
if (party==null) {
this.party = new ArrayList<>();
}
FieldWithMeta9.FieldWithMeta9Builder result;
return getIndex(party, _index, () -> {
FieldWithMeta9.FieldWithMeta9Builder newParty = FieldWithMeta9.builder();
return newParty;
});
}
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(FieldWithMeta9 party) {
if (party!=null) this.party.add(party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(FieldWithMeta9 party, int _idx) {
getIndex(this.party, _idx, () -> party.toBuilder());
return this;
}
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder addParty(List extends FieldWithMeta9> partys) {
if (partys != null) {
for (FieldWithMeta9 toAdd : partys) {
this.party.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("party")
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder setParty(List extends FieldWithMeta9> 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 PartyTradeIdentifier9 build() {
return new PartyTradeIdentifier9.PartyTradeIdentifier9Impl(this);
}
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder 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().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public PartyTradeIdentifier9.PartyTradeIdentifier9Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
PartyTradeIdentifier9.PartyTradeIdentifier9Builder o = (PartyTradeIdentifier9.PartyTradeIdentifier9Builder) 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;
PartyTradeIdentifier9 _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 "PartyTradeIdentifier9Builder {" +
"party=" + this.party +
'}';
}
}
}