All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rosetta.externalsynonym.model.PartyTradeIdentifier1 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
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 getParty();

	/*********************** Build Methods  ***********************/
	PartyTradeIdentifier1 build();
	
	PartyTradeIdentifier1.PartyTradeIdentifier1Builder toBuilder();
	
	static PartyTradeIdentifier1.PartyTradeIdentifier1Builder builder() {
		return new PartyTradeIdentifier1.PartyTradeIdentifier1BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class 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 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 party4);
		PartyTradeIdentifier1.PartyTradeIdentifier1Builder setParty(List party5);
		PartyTradeIdentifier1.PartyTradeIdentifier1Builder addPartyValue(List party6);
		PartyTradeIdentifier1.PartyTradeIdentifier1Builder setPartyValue(List 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 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 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 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 partys) {
			if (partys != null) {
				for (FieldWithMetaString toAdd : partys) {
					this.party.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("party")
		public PartyTradeIdentifier1.PartyTradeIdentifier1Builder setParty(List 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 partys) {
			if (partys != null) {
				for (String toAdd : partys) {
					this.addPartyValue(toAdd);
				}
			}
			return this;
		}
		
		@Override
		public PartyTradeIdentifier1.PartyTradeIdentifier1Builder setPartyValue(List 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 +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy