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

com.rosetta.mappingprocessortest.model.PayerReceiver Maven / Gradle / Ivy

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

import com.rosetta.mappingprocessortest.model.Party;
import com.rosetta.mappingprocessortest.model.PayerReceiver;
import com.rosetta.mappingprocessortest.model.PayerReceiver.PayerReceiverBuilder;
import com.rosetta.mappingprocessortest.model.PayerReceiver.PayerReceiverBuilderImpl;
import com.rosetta.mappingprocessortest.model.PayerReceiver.PayerReceiverImpl;
import com.rosetta.mappingprocessortest.model.meta.PayerReceiverMeta;
import com.rosetta.mappingprocessortest.model.metafields.ReferenceWithMetaParty;
import com.rosetta.mappingprocessortest.model.metafields.ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder;
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="PayerReceiver", builder=PayerReceiver.PayerReceiverBuilderImpl.class, version="test")
public interface PayerReceiver extends RosettaModelObject {

	PayerReceiverMeta metaData = new PayerReceiverMeta();

	/*********************** Getter Methods  ***********************/
	ReferenceWithMetaParty getPayerPartyReference();
	ReferenceWithMetaParty getReceiverPartyReference();

	/*********************** Build Methods  ***********************/
	PayerReceiver build();
	
	PayerReceiver.PayerReceiverBuilder toBuilder();
	
	static PayerReceiver.PayerReceiverBuilder builder() {
		return new PayerReceiver.PayerReceiverBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return PayerReceiver.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("payerPartyReference"), processor, ReferenceWithMetaParty.class, getPayerPartyReference());
		processRosetta(path.newSubPath("receiverPartyReference"), processor, ReferenceWithMetaParty.class, getReceiverPartyReference());
	}
	

	/*********************** Builder Interface  ***********************/
	interface PayerReceiverBuilder extends PayerReceiver, RosettaModelObjectBuilder {
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreatePayerPartyReference();
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getPayerPartyReference();
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreateReceiverPartyReference();
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getReceiverPartyReference();
		PayerReceiver.PayerReceiverBuilder setPayerPartyReference(ReferenceWithMetaParty payerPartyReference0);
		PayerReceiver.PayerReceiverBuilder setPayerPartyReferenceValue(Party payerPartyReference1);
		PayerReceiver.PayerReceiverBuilder setReceiverPartyReference(ReferenceWithMetaParty receiverPartyReference0);
		PayerReceiver.PayerReceiverBuilder setReceiverPartyReferenceValue(Party receiverPartyReference1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("payerPartyReference"), processor, ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder.class, getPayerPartyReference());
			processRosetta(path.newSubPath("receiverPartyReference"), processor, ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder.class, getReceiverPartyReference());
		}
		

		PayerReceiver.PayerReceiverBuilder prune();
	}

	/*********************** Immutable Implementation of PayerReceiver  ***********************/
	class PayerReceiverImpl implements PayerReceiver {
		private final ReferenceWithMetaParty payerPartyReference;
		private final ReferenceWithMetaParty receiverPartyReference;
		
		protected PayerReceiverImpl(PayerReceiver.PayerReceiverBuilder builder) {
			this.payerPartyReference = ofNullable(builder.getPayerPartyReference()).map(f->f.build()).orElse(null);
			this.receiverPartyReference = ofNullable(builder.getReceiverPartyReference()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("payerPartyReference")
		public ReferenceWithMetaParty getPayerPartyReference() {
			return payerPartyReference;
		}
		
		@Override
		@RosettaAttribute("receiverPartyReference")
		public ReferenceWithMetaParty getReceiverPartyReference() {
			return receiverPartyReference;
		}
		
		@Override
		public PayerReceiver build() {
			return this;
		}
		
		@Override
		public PayerReceiver.PayerReceiverBuilder toBuilder() {
			PayerReceiver.PayerReceiverBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(PayerReceiver.PayerReceiverBuilder builder) {
			ofNullable(getPayerPartyReference()).ifPresent(builder::setPayerPartyReference);
			ofNullable(getReceiverPartyReference()).ifPresent(builder::setReceiverPartyReference);
		}

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

	/*********************** Builder Implementation of PayerReceiver  ***********************/
	class PayerReceiverBuilderImpl implements PayerReceiver.PayerReceiverBuilder {
	
		protected ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder payerPartyReference;
		protected ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder receiverPartyReference;
	
		public PayerReceiverBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("payerPartyReference")
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getPayerPartyReference() {
			return payerPartyReference;
		}
		
		@Override
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreatePayerPartyReference() {
			ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder result;
			if (payerPartyReference!=null) {
				result = payerPartyReference;
			}
			else {
				result = payerPartyReference = ReferenceWithMetaParty.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("receiverPartyReference")
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getReceiverPartyReference() {
			return receiverPartyReference;
		}
		
		@Override
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreateReceiverPartyReference() {
			ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder result;
			if (receiverPartyReference!=null) {
				result = receiverPartyReference;
			}
			else {
				result = receiverPartyReference = ReferenceWithMetaParty.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("payerPartyReference")
		public PayerReceiver.PayerReceiverBuilder setPayerPartyReference(ReferenceWithMetaParty payerPartyReference) {
			this.payerPartyReference = payerPartyReference==null?null:payerPartyReference.toBuilder();
			return this;
		}
		@Override
		public PayerReceiver.PayerReceiverBuilder setPayerPartyReferenceValue(Party payerPartyReference) {
			this.getOrCreatePayerPartyReference().setValue(payerPartyReference);
			return this;
		}
		@Override
		@RosettaAttribute("receiverPartyReference")
		public PayerReceiver.PayerReceiverBuilder setReceiverPartyReference(ReferenceWithMetaParty receiverPartyReference) {
			this.receiverPartyReference = receiverPartyReference==null?null:receiverPartyReference.toBuilder();
			return this;
		}
		@Override
		public PayerReceiver.PayerReceiverBuilder setReceiverPartyReferenceValue(Party receiverPartyReference) {
			this.getOrCreateReceiverPartyReference().setValue(receiverPartyReference);
			return this;
		}
		
		@Override
		public PayerReceiver build() {
			return new PayerReceiver.PayerReceiverImpl(this);
		}
		
		@Override
		public PayerReceiver.PayerReceiverBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PayerReceiver.PayerReceiverBuilder prune() {
			if (payerPartyReference!=null && !payerPartyReference.prune().hasData()) payerPartyReference = null;
			if (receiverPartyReference!=null && !receiverPartyReference.prune().hasData()) receiverPartyReference = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPayerPartyReference()!=null && getPayerPartyReference().hasData()) return true;
			if (getReceiverPartyReference()!=null && getReceiverPartyReference().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public PayerReceiver.PayerReceiverBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			PayerReceiver.PayerReceiverBuilder o = (PayerReceiver.PayerReceiverBuilder) other;
			
			merger.mergeRosetta(getPayerPartyReference(), o.getPayerPartyReference(), this::setPayerPartyReference);
			merger.mergeRosetta(getReceiverPartyReference(), o.getReceiverPartyReference(), this::setReceiverPartyReference);
			
			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;
		
			PayerReceiver _that = getType().cast(o);
		
			if (!Objects.equals(payerPartyReference, _that.getPayerPartyReference())) return false;
			if (!Objects.equals(receiverPartyReference, _that.getReceiverPartyReference())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (payerPartyReference != null ? payerPartyReference.hashCode() : 0);
			_result = 31 * _result + (receiverPartyReference != null ? receiverPartyReference.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "PayerReceiverBuilder {" +
				"payerPartyReference=" + this.payerPartyReference + ", " +
				"receiverPartyReference=" + this.receiverPartyReference +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy