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.
com.rosetta.jptlegalagreement.model.Party Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.Account;
import com.rosetta.jptlegalagreement.model.Party;
import com.rosetta.jptlegalagreement.model.Party.PartyBuilder;
import com.rosetta.jptlegalagreement.model.Party.PartyBuilderImpl;
import com.rosetta.jptlegalagreement.model.Party.PartyImpl;
import com.rosetta.jptlegalagreement.model.meta.PartyMeta;
import com.rosetta.model.lib.GlobalKey;
import com.rosetta.model.lib.GlobalKey.GlobalKeyBuilder;
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.model.metafields.MetaFields;
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="Party", builder=Party.PartyBuilderImpl.class, version="test")
public interface Party extends RosettaModelObject, GlobalKey {
PartyMeta metaData = new PartyMeta();
/*********************** Getter Methods ***********************/
List extends FieldWithMetaString> getPartyId();
FieldWithMetaString getName();
Account getAccount();
MetaFields getMeta();
/*********************** Build Methods ***********************/
Party build();
Party.PartyBuilder toBuilder();
static Party.PartyBuilder builder() {
return new Party.PartyBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Party> metaData() {
return metaData;
}
@Override
default Class extends Party> getType() {
return Party.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("partyId"), processor, FieldWithMetaString.class, getPartyId());
processRosetta(path.newSubPath("name"), processor, FieldWithMetaString.class, getName());
processRosetta(path.newSubPath("account"), processor, Account.class, getAccount());
processRosetta(path.newSubPath("meta"), processor, MetaFields.class, getMeta());
}
/*********************** Builder Interface ***********************/
interface PartyBuilder extends Party, RosettaModelObjectBuilder {
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreatePartyId(int _index);
List extends FieldWithMetaString.FieldWithMetaStringBuilder> getPartyId();
FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateName();
FieldWithMetaString.FieldWithMetaStringBuilder getName();
Account.AccountBuilder getOrCreateAccount();
Account.AccountBuilder getAccount();
MetaFields.MetaFieldsBuilder getOrCreateMeta();
MetaFields.MetaFieldsBuilder getMeta();
Party.PartyBuilder addPartyId(FieldWithMetaString partyId0);
Party.PartyBuilder addPartyId(FieldWithMetaString partyId1, int _idx);
Party.PartyBuilder addPartyIdValue(String partyId2);
Party.PartyBuilder addPartyIdValue(String partyId3, int _idx);
Party.PartyBuilder addPartyId(List extends FieldWithMetaString> partyId4);
Party.PartyBuilder setPartyId(List extends FieldWithMetaString> partyId5);
Party.PartyBuilder addPartyIdValue(List extends String> partyId6);
Party.PartyBuilder setPartyIdValue(List extends String> partyId7);
Party.PartyBuilder setName(FieldWithMetaString name0);
Party.PartyBuilder setNameValue(String name1);
Party.PartyBuilder setAccount(Account account);
Party.PartyBuilder setMeta(MetaFields meta);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("partyId"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getPartyId());
processRosetta(path.newSubPath("name"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getName());
processRosetta(path.newSubPath("account"), processor, Account.AccountBuilder.class, getAccount());
processRosetta(path.newSubPath("meta"), processor, MetaFields.MetaFieldsBuilder.class, getMeta());
}
Party.PartyBuilder prune();
}
/*********************** Immutable Implementation of Party ***********************/
class PartyImpl implements Party {
private final List extends FieldWithMetaString> partyId;
private final FieldWithMetaString name;
private final Account account;
private final MetaFields meta;
protected PartyImpl(Party.PartyBuilder builder) {
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);
this.name = ofNullable(builder.getName()).map(f->f.build()).orElse(null);
this.account = ofNullable(builder.getAccount()).map(f->f.build()).orElse(null);
this.meta = ofNullable(builder.getMeta()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("partyId")
public List extends FieldWithMetaString> getPartyId() {
return partyId;
}
@Override
@RosettaAttribute("name")
public FieldWithMetaString getName() {
return name;
}
@Override
@RosettaAttribute("account")
public Account getAccount() {
return account;
}
@Override
@RosettaAttribute("meta")
public MetaFields getMeta() {
return meta;
}
@Override
public Party build() {
return this;
}
@Override
public Party.PartyBuilder toBuilder() {
Party.PartyBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Party.PartyBuilder builder) {
ofNullable(getPartyId()).ifPresent(builder::setPartyId);
ofNullable(getName()).ifPresent(builder::setName);
ofNullable(getAccount()).ifPresent(builder::setAccount);
ofNullable(getMeta()).ifPresent(builder::setMeta);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Party _that = getType().cast(o);
if (!ListEquals.listEquals(partyId, _that.getPartyId())) return false;
if (!Objects.equals(name, _that.getName())) return false;
if (!Objects.equals(account, _that.getAccount())) return false;
if (!Objects.equals(meta, _that.getMeta())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (partyId != null ? partyId.hashCode() : 0);
_result = 31 * _result + (name != null ? name.hashCode() : 0);
_result = 31 * _result + (account != null ? account.hashCode() : 0);
_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Party {" +
"partyId=" + this.partyId + ", " +
"name=" + this.name + ", " +
"account=" + this.account + ", " +
"meta=" + this.meta +
'}';
}
}
/*********************** Builder Implementation of Party ***********************/
class PartyBuilderImpl implements Party.PartyBuilder, GlobalKeyBuilder {
protected List partyId = new ArrayList<>();
protected FieldWithMetaString.FieldWithMetaStringBuilder name;
protected Account.AccountBuilder account;
protected MetaFields.MetaFieldsBuilder meta;
public PartyBuilderImpl() {
}
@Override
@RosettaAttribute("partyId")
public List extends FieldWithMetaString.FieldWithMetaStringBuilder> getPartyId() {
return partyId;
}
public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreatePartyId(int _index) {
if (partyId==null) {
this.partyId = new ArrayList<>();
}
FieldWithMetaString.FieldWithMetaStringBuilder result;
return getIndex(partyId, _index, () -> {
FieldWithMetaString.FieldWithMetaStringBuilder newPartyId = FieldWithMetaString.builder();
return newPartyId;
});
}
@Override
@RosettaAttribute("name")
public FieldWithMetaString.FieldWithMetaStringBuilder getName() {
return name;
}
@Override
public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateName() {
FieldWithMetaString.FieldWithMetaStringBuilder result;
if (name!=null) {
result = name;
}
else {
result = name = FieldWithMetaString.builder();
}
return result;
}
@Override
@RosettaAttribute("account")
public Account.AccountBuilder getAccount() {
return account;
}
@Override
public Account.AccountBuilder getOrCreateAccount() {
Account.AccountBuilder result;
if (account!=null) {
result = account;
}
else {
result = account = Account.builder();
}
return result;
}
@Override
@RosettaAttribute("meta")
public MetaFields.MetaFieldsBuilder getMeta() {
return meta;
}
@Override
public MetaFields.MetaFieldsBuilder getOrCreateMeta() {
MetaFields.MetaFieldsBuilder result;
if (meta!=null) {
result = meta;
}
else {
result = meta = MetaFields.builder();
}
return result;
}
@Override
public Party.PartyBuilder addPartyId(FieldWithMetaString partyId) {
if (partyId!=null) this.partyId.add(partyId.toBuilder());
return this;
}
@Override
public Party.PartyBuilder addPartyId(FieldWithMetaString partyId, int _idx) {
getIndex(this.partyId, _idx, () -> partyId.toBuilder());
return this;
}
@Override
public Party.PartyBuilder addPartyIdValue(String partyId) {
this.getOrCreatePartyId(-1).setValue(partyId);
return this;
}
@Override
public Party.PartyBuilder addPartyIdValue(String partyId, int _idx) {
this.getOrCreatePartyId(_idx).setValue(partyId);
return this;
}
@Override
public Party.PartyBuilder addPartyId(List extends FieldWithMetaString> partyIds) {
if (partyIds != null) {
for (FieldWithMetaString toAdd : partyIds) {
this.partyId.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("partyId")
public Party.PartyBuilder setPartyId(List extends FieldWithMetaString> 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 Party.PartyBuilder addPartyIdValue(List extends String> partyIds) {
if (partyIds != null) {
for (String toAdd : partyIds) {
this.addPartyIdValue(toAdd);
}
}
return this;
}
@Override
public Party.PartyBuilder setPartyIdValue(List extends String> partyIds) {
this.partyId.clear();
if (partyIds!=null) {
partyIds.forEach(this::addPartyIdValue);
}
return this;
}
@Override
@RosettaAttribute("name")
public Party.PartyBuilder setName(FieldWithMetaString name) {
this.name = name==null?null:name.toBuilder();
return this;
}
@Override
public Party.PartyBuilder setNameValue(String name) {
this.getOrCreateName().setValue(name);
return this;
}
@Override
@RosettaAttribute("account")
public Party.PartyBuilder setAccount(Account account) {
this.account = account==null?null:account.toBuilder();
return this;
}
@Override
@RosettaAttribute("meta")
public Party.PartyBuilder setMeta(MetaFields meta) {
this.meta = meta==null?null:meta.toBuilder();
return this;
}
@Override
public Party build() {
return new Party.PartyImpl(this);
}
@Override
public Party.PartyBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Party.PartyBuilder prune() {
partyId = partyId.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
if (name!=null && !name.prune().hasData()) name = null;
if (account!=null && !account.prune().hasData()) account = null;
if (meta!=null && !meta.prune().hasData()) meta = null;
return this;
}
@Override
public boolean hasData() {
if (getPartyId()!=null && !getPartyId().isEmpty()) return true;
if (getName()!=null) return true;
if (getAccount()!=null && getAccount().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Party.PartyBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Party.PartyBuilder o = (Party.PartyBuilder) other;
merger.mergeRosetta(getPartyId(), o.getPartyId(), this::getOrCreatePartyId);
merger.mergeRosetta(getName(), o.getName(), this::setName);
merger.mergeRosetta(getAccount(), o.getAccount(), this::setAccount);
merger.mergeRosetta(getMeta(), o.getMeta(), this::setMeta);
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;
Party _that = getType().cast(o);
if (!ListEquals.listEquals(partyId, _that.getPartyId())) return false;
if (!Objects.equals(name, _that.getName())) return false;
if (!Objects.equals(account, _that.getAccount())) return false;
if (!Objects.equals(meta, _that.getMeta())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (partyId != null ? partyId.hashCode() : 0);
_result = 31 * _result + (name != null ? name.hashCode() : 0);
_result = 31 * _result + (account != null ? account.hashCode() : 0);
_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PartyBuilder {" +
"partyId=" + this.partyId + ", " +
"name=" + this.name + ", " +
"account=" + this.account + ", " +
"meta=" + this.meta +
'}';
}
}
}