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

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

The newest version!
package com.rosetta.metatest.model;

import com.rosetta.metatest.model.Party1;
import com.rosetta.metatest.model.PartyTradeIdentifier2;
import com.rosetta.metatest.model.PartyTradeIdentifier2.PartyTradeIdentifier2Builder;
import com.rosetta.metatest.model.PartyTradeIdentifier2.PartyTradeIdentifier2BuilderImpl;
import com.rosetta.metatest.model.PartyTradeIdentifier2.PartyTradeIdentifier2Impl;
import com.rosetta.metatest.model.meta.PartyTradeIdentifier2Meta;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaParty1;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder;
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 java.util.Objects;

import static java.util.Optional.ofNullable;

/**
 * @version test
 */
@RosettaDataType(value="PartyTradeIdentifier2", builder=PartyTradeIdentifier2.PartyTradeIdentifier2BuilderImpl.class, version="test")
public interface PartyTradeIdentifier2 extends RosettaModelObject {

	PartyTradeIdentifier2Meta metaData = new PartyTradeIdentifier2Meta();

	/*********************** Getter Methods  ***********************/
	ReferenceWithMetaParty1 getPartyReference();

	/*********************** Build Methods  ***********************/
	PartyTradeIdentifier2 build();
	
	PartyTradeIdentifier2.PartyTradeIdentifier2Builder toBuilder();
	
	static PartyTradeIdentifier2.PartyTradeIdentifier2Builder builder() {
		return new PartyTradeIdentifier2.PartyTradeIdentifier2BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return PartyTradeIdentifier2.class;
	}
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("partyReference"), processor, ReferenceWithMetaParty1.class, getPartyReference());
	}
	

	/*********************** Builder Interface  ***********************/
	interface PartyTradeIdentifier2Builder extends PartyTradeIdentifier2, RosettaModelObjectBuilder {
		ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getOrCreatePartyReference();
		@Override
		ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getPartyReference();
		PartyTradeIdentifier2.PartyTradeIdentifier2Builder setPartyReference(ReferenceWithMetaParty1 partyReference);
		PartyTradeIdentifier2.PartyTradeIdentifier2Builder setPartyReferenceValue(Party1 partyReference);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("partyReference"), processor, ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder.class, getPartyReference());
		}
		

		PartyTradeIdentifier2.PartyTradeIdentifier2Builder prune();
	}

	/*********************** Immutable Implementation of PartyTradeIdentifier2  ***********************/
	class PartyTradeIdentifier2Impl implements PartyTradeIdentifier2 {
		private final ReferenceWithMetaParty1 partyReference;
		
		protected PartyTradeIdentifier2Impl(PartyTradeIdentifier2.PartyTradeIdentifier2Builder builder) {
			this.partyReference = ofNullable(builder.getPartyReference()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("partyReference")
		public ReferenceWithMetaParty1 getPartyReference() {
			return partyReference;
		}
		
		@Override
		public PartyTradeIdentifier2 build() {
			return this;
		}
		
		@Override
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder toBuilder() {
			PartyTradeIdentifier2.PartyTradeIdentifier2Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(PartyTradeIdentifier2.PartyTradeIdentifier2Builder builder) {
			ofNullable(getPartyReference()).ifPresent(builder::setPartyReference);
		}

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

	/*********************** Builder Implementation of PartyTradeIdentifier2  ***********************/
	class PartyTradeIdentifier2BuilderImpl implements PartyTradeIdentifier2.PartyTradeIdentifier2Builder {
	
		protected ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder partyReference;
		
		@Override
		@RosettaAttribute("partyReference")
		public ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getPartyReference() {
			return partyReference;
		}
		
		@Override
		public ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getOrCreatePartyReference() {
			ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder result;
			if (partyReference!=null) {
				result = partyReference;
			}
			else {
				result = partyReference = ReferenceWithMetaParty1.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("partyReference")
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder setPartyReference(ReferenceWithMetaParty1 _partyReference) {
			this.partyReference = _partyReference == null ? null : _partyReference.toBuilder();
			return this;
		}
		
		@Override
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder setPartyReferenceValue(Party1 _partyReference) {
			this.getOrCreatePartyReference().setValue(_partyReference);
			return this;
		}
		
		@Override
		public PartyTradeIdentifier2 build() {
			return new PartyTradeIdentifier2.PartyTradeIdentifier2Impl(this);
		}
		
		@Override
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder prune() {
			if (partyReference!=null && !partyReference.prune().hasData()) partyReference = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPartyReference()!=null && getPartyReference().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PartyTradeIdentifier2.PartyTradeIdentifier2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			PartyTradeIdentifier2.PartyTradeIdentifier2Builder o = (PartyTradeIdentifier2.PartyTradeIdentifier2Builder) other;
			
			merger.mergeRosetta(getPartyReference(), o.getPartyReference(), this::setPartyReference);
			
			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;
		
			PartyTradeIdentifier2 _that = getType().cast(o);
		
			if (!Objects.equals(partyReference, _that.getPartyReference())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyReference != null ? partyReference.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "PartyTradeIdentifier2Builder {" +
				"partyReference=" + this.partyReference +
			'}';
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy