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

com.rosetta.metatest.model.PartyTradeIdentifier5 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.PartyTradeIdentifier5;
import com.rosetta.metatest.model.PartyTradeIdentifier5.PartyTradeIdentifier5Builder;
import com.rosetta.metatest.model.PartyTradeIdentifier5.PartyTradeIdentifier5BuilderImpl;
import com.rosetta.metatest.model.PartyTradeIdentifier5.PartyTradeIdentifier5Impl;
import com.rosetta.metatest.model.meta.PartyTradeIdentifier5Meta;
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.ReferenceWithMetaBigDecimal;
import com.rosetta.model.metafields.ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder;
import com.rosetta.util.ListEquals;
import java.math.BigDecimal;
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="PartyTradeIdentifier5", builder=PartyTradeIdentifier5.PartyTradeIdentifier5BuilderImpl.class, version="test")
public interface PartyTradeIdentifier5 extends RosettaModelObject {

	PartyTradeIdentifier5Meta metaData = new PartyTradeIdentifier5Meta();

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

	/*********************** Build Methods  ***********************/
	PartyTradeIdentifier5 build();
	
	PartyTradeIdentifier5.PartyTradeIdentifier5Builder toBuilder();
	
	static PartyTradeIdentifier5.PartyTradeIdentifier5Builder builder() {
		return new PartyTradeIdentifier5.PartyTradeIdentifier5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return PartyTradeIdentifier5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("partyCount"), processor, ReferenceWithMetaBigDecimal.class, getPartyCount());
	}
	

	/*********************** Builder Interface  ***********************/
	interface PartyTradeIdentifier5Builder extends PartyTradeIdentifier5, RosettaModelObjectBuilder {
		ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder getOrCreatePartyCount(int _index);
		List getPartyCount();
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(ReferenceWithMetaBigDecimal partyCount0);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(ReferenceWithMetaBigDecimal partyCount1, int _idx);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(BigDecimal partyCount2);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(BigDecimal partyCount3, int _idx);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(List partyCount4);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder setPartyCount(List partyCount5);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(List partyCount6);
		PartyTradeIdentifier5.PartyTradeIdentifier5Builder setPartyCountValue(List partyCount7);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("partyCount"), processor, ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder.class, getPartyCount());
		}
		

		PartyTradeIdentifier5.PartyTradeIdentifier5Builder prune();
	}

	/*********************** Immutable Implementation of PartyTradeIdentifier5  ***********************/
	class PartyTradeIdentifier5Impl implements PartyTradeIdentifier5 {
		private final List partyCount;
		
		protected PartyTradeIdentifier5Impl(PartyTradeIdentifier5.PartyTradeIdentifier5Builder builder) {
			this.partyCount = ofNullable(builder.getPartyCount()).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("partyCount")
		public List getPartyCount() {
			return partyCount;
		}
		
		@Override
		public PartyTradeIdentifier5 build() {
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder toBuilder() {
			PartyTradeIdentifier5.PartyTradeIdentifier5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(PartyTradeIdentifier5.PartyTradeIdentifier5Builder builder) {
			ofNullable(getPartyCount()).ifPresent(builder::setPartyCount);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			PartyTradeIdentifier5 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(partyCount, _that.getPartyCount())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyCount != null ? partyCount.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "PartyTradeIdentifier5 {" +
				"partyCount=" + this.partyCount +
			'}';
		}
	}

	/*********************** Builder Implementation of PartyTradeIdentifier5  ***********************/
	class PartyTradeIdentifier5BuilderImpl implements PartyTradeIdentifier5.PartyTradeIdentifier5Builder {
	
		protected List partyCount = new ArrayList<>();
	
		public PartyTradeIdentifier5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("partyCount")
		public List getPartyCount() {
			return partyCount;
		}
		
		public ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder getOrCreatePartyCount(int _index) {
		
			if (partyCount==null) {
				this.partyCount = new ArrayList<>();
			}
			ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder result;
			return getIndex(partyCount, _index, () -> {
						ReferenceWithMetaBigDecimal.ReferenceWithMetaBigDecimalBuilder newPartyCount = ReferenceWithMetaBigDecimal.builder();
						return newPartyCount;
					});
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(ReferenceWithMetaBigDecimal partyCount) {
			if (partyCount!=null) this.partyCount.add(partyCount.toBuilder());
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(ReferenceWithMetaBigDecimal partyCount, int _idx) {
			getIndex(this.partyCount, _idx, () -> partyCount.toBuilder());
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(BigDecimal partyCount) {
			this.getOrCreatePartyCount(-1).setValue(partyCount);
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(BigDecimal partyCount, int _idx) {
			this.getOrCreatePartyCount(_idx).setValue(partyCount);
			return this;
		}
		@Override 
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCount(List partyCounts) {
			if (partyCounts != null) {
				for (ReferenceWithMetaBigDecimal toAdd : partyCounts) {
					this.partyCount.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("partyCount")
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder setPartyCount(List partyCounts) {
			if (partyCounts == null)  {
				this.partyCount = new ArrayList<>();
			}
			else {
				this.partyCount = partyCounts.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder addPartyCountValue(List partyCounts) {
			if (partyCounts != null) {
				for (BigDecimal toAdd : partyCounts) {
					this.addPartyCountValue(toAdd);
				}
			}
			return this;
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder setPartyCountValue(List partyCounts) {
			this.partyCount.clear();
			if (partyCounts!=null) {
				partyCounts.forEach(this::addPartyCountValue);
			}
			return this;
		}
		
		
		@Override
		public PartyTradeIdentifier5 build() {
			return new PartyTradeIdentifier5.PartyTradeIdentifier5Impl(this);
		}
		
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder prune() {
			partyCount = partyCount.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPartyCount()!=null && !getPartyCount().isEmpty()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PartyTradeIdentifier5.PartyTradeIdentifier5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			PartyTradeIdentifier5.PartyTradeIdentifier5Builder o = (PartyTradeIdentifier5.PartyTradeIdentifier5Builder) other;
			
			merger.mergeRosetta(getPartyCount(), o.getPartyCount(), this::getOrCreatePartyCount);
			
			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;
		
			PartyTradeIdentifier5 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(partyCount, _that.getPartyCount())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyCount != null ? partyCount.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "PartyTradeIdentifier5Builder {" +
				"partyCount=" + this.partyCount +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy