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

com.rosetta.metatest.model.PartyTradeIdentifier7 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.metatest.model;

import com.google.common.collect.ImmutableList;
import com.rosetta.metatest.model.PartyTradeIdentifier7;
import com.rosetta.metatest.model.PartyTradeIdentifier7.PartyTradeIdentifier7Builder;
import com.rosetta.metatest.model.PartyTradeIdentifier7.PartyTradeIdentifier7BuilderImpl;
import com.rosetta.metatest.model.PartyTradeIdentifier7.PartyTradeIdentifier7Impl;
import com.rosetta.metatest.model.meta.PartyTradeIdentifier7Meta;
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="PartyTradeIdentifier7", builder=PartyTradeIdentifier7.PartyTradeIdentifier7BuilderImpl.class, version="test")
public interface PartyTradeIdentifier7 extends RosettaModelObject {

	PartyTradeIdentifier7Meta metaData = new PartyTradeIdentifier7Meta();

	/*********************** Getter Methods  ***********************/
	List getParty();

	/*********************** Build Methods  ***********************/
	PartyTradeIdentifier7 build();
	
	PartyTradeIdentifier7.PartyTradeIdentifier7Builder toBuilder();
	
	static PartyTradeIdentifier7.PartyTradeIdentifier7Builder builder() {
		return new PartyTradeIdentifier7.PartyTradeIdentifier7BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return PartyTradeIdentifier7.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.class, getParty());
	}
	

	/*********************** Builder Interface  ***********************/
	interface PartyTradeIdentifier7Builder extends PartyTradeIdentifier7, RosettaModelObjectBuilder {
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateParty(int _index);
		List getParty();
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(FieldWithMetaString party0);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(FieldWithMetaString party1, int _idx);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(String party2);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(String party3, int _idx);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(List party4);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder setParty(List party5);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(List party6);
		PartyTradeIdentifier7.PartyTradeIdentifier7Builder setPartyValue(List party7);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("party"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getParty());
		}
		

		PartyTradeIdentifier7.PartyTradeIdentifier7Builder prune();
	}

	/*********************** Immutable Implementation of PartyTradeIdentifier7  ***********************/
	class PartyTradeIdentifier7Impl implements PartyTradeIdentifier7 {
		private final List party;
		
		protected PartyTradeIdentifier7Impl(PartyTradeIdentifier7.PartyTradeIdentifier7Builder 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 PartyTradeIdentifier7 build() {
			return this;
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder toBuilder() {
			PartyTradeIdentifier7.PartyTradeIdentifier7Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(PartyTradeIdentifier7.PartyTradeIdentifier7Builder 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;
		
			PartyTradeIdentifier7 _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 "PartyTradeIdentifier7 {" +
				"party=" + this.party +
			'}';
		}
	}

	/*********************** Builder Implementation of PartyTradeIdentifier7  ***********************/
	class PartyTradeIdentifier7BuilderImpl implements PartyTradeIdentifier7.PartyTradeIdentifier7Builder {
	
		protected List party = new ArrayList<>();
	
		public PartyTradeIdentifier7BuilderImpl() {
		}
	
		@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 PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(FieldWithMetaString party) {
			if (party!=null) this.party.add(party.toBuilder());
			return this;
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(FieldWithMetaString party, int _idx) {
			getIndex(this.party, _idx, () -> party.toBuilder());
			return this;
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(String party) {
			this.getOrCreateParty(-1).setValue(party);
			return this;
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(String party, int _idx) {
			this.getOrCreateParty(_idx).setValue(party);
			return this;
		}
		@Override 
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder addParty(List partys) {
			if (partys != null) {
				for (FieldWithMetaString toAdd : partys) {
					this.party.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("party")
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder 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 PartyTradeIdentifier7.PartyTradeIdentifier7Builder addPartyValue(List partys) {
			if (partys != null) {
				for (String toAdd : partys) {
					this.addPartyValue(toAdd);
				}
			}
			return this;
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder setPartyValue(List partys) {
			this.party.clear();
			if (partys!=null) {
				partys.forEach(this::addPartyValue);
			}
			return this;
		}
		
		
		@Override
		public PartyTradeIdentifier7 build() {
			return new PartyTradeIdentifier7.PartyTradeIdentifier7Impl(this);
		}
		
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PartyTradeIdentifier7.PartyTradeIdentifier7Builder 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 PartyTradeIdentifier7.PartyTradeIdentifier7Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			PartyTradeIdentifier7.PartyTradeIdentifier7Builder o = (PartyTradeIdentifier7.PartyTradeIdentifier7Builder) 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;
		
			PartyTradeIdentifier7 _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 "PartyTradeIdentifier7Builder {" +
				"party=" + this.party +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy