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

com.rosetta.jptlegalagreement.model.CustodyArrangements Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.CustodianEvent;
import com.rosetta.jptlegalagreement.model.CustodyArrangements;
import com.rosetta.jptlegalagreement.model.CustodyArrangements.CustodyArrangementsBuilder;
import com.rosetta.jptlegalagreement.model.CustodyArrangements.CustodyArrangementsBuilderImpl;
import com.rosetta.jptlegalagreement.model.CustodyArrangements.CustodyArrangementsImpl;
import com.rosetta.jptlegalagreement.model.CustodyArrangementsElection;
import com.rosetta.jptlegalagreement.model.meta.CustodyArrangementsMeta;
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.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="CustodyArrangements", builder=CustodyArrangements.CustodyArrangementsBuilderImpl.class, version="test")
public interface CustodyArrangements extends RosettaModelObject {

	CustodyArrangementsMeta metaData = new CustodyArrangementsMeta();

	/*********************** Getter Methods  ***********************/
	List getPartyElection();
	CustodianEvent getCustodianEvent();
	Boolean getIsCreditSupportDocument();
	Boolean getHasControlAgreementLanguage();
	String getOtherProvisions();

	/*********************** Build Methods  ***********************/
	CustodyArrangements build();
	
	CustodyArrangements.CustodyArrangementsBuilder toBuilder();
	
	static CustodyArrangements.CustodyArrangementsBuilder builder() {
		return new CustodyArrangements.CustodyArrangementsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return CustodyArrangements.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("partyElection"), processor, CustodyArrangementsElection.class, getPartyElection());
		processRosetta(path.newSubPath("custodianEvent"), processor, CustodianEvent.class, getCustodianEvent());
		processor.processBasic(path.newSubPath("isCreditSupportDocument"), Boolean.class, getIsCreditSupportDocument(), this);
		processor.processBasic(path.newSubPath("hasControlAgreementLanguage"), Boolean.class, getHasControlAgreementLanguage(), this);
		processor.processBasic(path.newSubPath("otherProvisions"), String.class, getOtherProvisions(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface CustodyArrangementsBuilder extends CustodyArrangements, RosettaModelObjectBuilder {
		CustodyArrangementsElection.CustodyArrangementsElectionBuilder getOrCreatePartyElection(int _index);
		List getPartyElection();
		CustodianEvent.CustodianEventBuilder getOrCreateCustodianEvent();
		CustodianEvent.CustodianEventBuilder getCustodianEvent();
		CustodyArrangements.CustodyArrangementsBuilder addPartyElection(CustodyArrangementsElection partyElection0);
		CustodyArrangements.CustodyArrangementsBuilder addPartyElection(CustodyArrangementsElection partyElection1, int _idx);
		CustodyArrangements.CustodyArrangementsBuilder addPartyElection(List partyElection2);
		CustodyArrangements.CustodyArrangementsBuilder setPartyElection(List partyElection3);
		CustodyArrangements.CustodyArrangementsBuilder setCustodianEvent(CustodianEvent custodianEvent);
		CustodyArrangements.CustodyArrangementsBuilder setIsCreditSupportDocument(Boolean isCreditSupportDocument);
		CustodyArrangements.CustodyArrangementsBuilder setHasControlAgreementLanguage(Boolean hasControlAgreementLanguage);
		CustodyArrangements.CustodyArrangementsBuilder setOtherProvisions(String otherProvisions);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("partyElection"), processor, CustodyArrangementsElection.CustodyArrangementsElectionBuilder.class, getPartyElection());
			processRosetta(path.newSubPath("custodianEvent"), processor, CustodianEvent.CustodianEventBuilder.class, getCustodianEvent());
			processor.processBasic(path.newSubPath("isCreditSupportDocument"), Boolean.class, getIsCreditSupportDocument(), this);
			processor.processBasic(path.newSubPath("hasControlAgreementLanguage"), Boolean.class, getHasControlAgreementLanguage(), this);
			processor.processBasic(path.newSubPath("otherProvisions"), String.class, getOtherProvisions(), this);
		}
		

		CustodyArrangements.CustodyArrangementsBuilder prune();
	}

	/*********************** Immutable Implementation of CustodyArrangements  ***********************/
	class CustodyArrangementsImpl implements CustodyArrangements {
		private final List partyElection;
		private final CustodianEvent custodianEvent;
		private final Boolean isCreditSupportDocument;
		private final Boolean hasControlAgreementLanguage;
		private final String otherProvisions;
		
		protected CustodyArrangementsImpl(CustodyArrangements.CustodyArrangementsBuilder builder) {
			this.partyElection = ofNullable(builder.getPartyElection()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
			this.custodianEvent = ofNullable(builder.getCustodianEvent()).map(f->f.build()).orElse(null);
			this.isCreditSupportDocument = builder.getIsCreditSupportDocument();
			this.hasControlAgreementLanguage = builder.getHasControlAgreementLanguage();
			this.otherProvisions = builder.getOtherProvisions();
		}
		
		@Override
		@RosettaAttribute("partyElection")
		public List getPartyElection() {
			return partyElection;
		}
		
		@Override
		@RosettaAttribute("custodianEvent")
		public CustodianEvent getCustodianEvent() {
			return custodianEvent;
		}
		
		@Override
		@RosettaAttribute("isCreditSupportDocument")
		public Boolean getIsCreditSupportDocument() {
			return isCreditSupportDocument;
		}
		
		@Override
		@RosettaAttribute("hasControlAgreementLanguage")
		public Boolean getHasControlAgreementLanguage() {
			return hasControlAgreementLanguage;
		}
		
		@Override
		@RosettaAttribute("otherProvisions")
		public String getOtherProvisions() {
			return otherProvisions;
		}
		
		@Override
		public CustodyArrangements build() {
			return this;
		}
		
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder toBuilder() {
			CustodyArrangements.CustodyArrangementsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(CustodyArrangements.CustodyArrangementsBuilder builder) {
			ofNullable(getPartyElection()).ifPresent(builder::setPartyElection);
			ofNullable(getCustodianEvent()).ifPresent(builder::setCustodianEvent);
			ofNullable(getIsCreditSupportDocument()).ifPresent(builder::setIsCreditSupportDocument);
			ofNullable(getHasControlAgreementLanguage()).ifPresent(builder::setHasControlAgreementLanguage);
			ofNullable(getOtherProvisions()).ifPresent(builder::setOtherProvisions);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			CustodyArrangements _that = getType().cast(o);
		
			if (!ListEquals.listEquals(partyElection, _that.getPartyElection())) return false;
			if (!Objects.equals(custodianEvent, _that.getCustodianEvent())) return false;
			if (!Objects.equals(isCreditSupportDocument, _that.getIsCreditSupportDocument())) return false;
			if (!Objects.equals(hasControlAgreementLanguage, _that.getHasControlAgreementLanguage())) return false;
			if (!Objects.equals(otherProvisions, _that.getOtherProvisions())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
			_result = 31 * _result + (custodianEvent != null ? custodianEvent.hashCode() : 0);
			_result = 31 * _result + (isCreditSupportDocument != null ? isCreditSupportDocument.hashCode() : 0);
			_result = 31 * _result + (hasControlAgreementLanguage != null ? hasControlAgreementLanguage.hashCode() : 0);
			_result = 31 * _result + (otherProvisions != null ? otherProvisions.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "CustodyArrangements {" +
				"partyElection=" + this.partyElection + ", " +
				"custodianEvent=" + this.custodianEvent + ", " +
				"isCreditSupportDocument=" + this.isCreditSupportDocument + ", " +
				"hasControlAgreementLanguage=" + this.hasControlAgreementLanguage + ", " +
				"otherProvisions=" + this.otherProvisions +
			'}';
		}
	}

	/*********************** Builder Implementation of CustodyArrangements  ***********************/
	class CustodyArrangementsBuilderImpl implements CustodyArrangements.CustodyArrangementsBuilder {
	
		protected List partyElection = new ArrayList<>();
		protected CustodianEvent.CustodianEventBuilder custodianEvent;
		protected Boolean isCreditSupportDocument;
		protected Boolean hasControlAgreementLanguage;
		protected String otherProvisions;
	
		public CustodyArrangementsBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("partyElection")
		public List getPartyElection() {
			return partyElection;
		}
		
		public CustodyArrangementsElection.CustodyArrangementsElectionBuilder getOrCreatePartyElection(int _index) {
		
			if (partyElection==null) {
				this.partyElection = new ArrayList<>();
			}
			CustodyArrangementsElection.CustodyArrangementsElectionBuilder result;
			return getIndex(partyElection, _index, () -> {
						CustodyArrangementsElection.CustodyArrangementsElectionBuilder newPartyElection = CustodyArrangementsElection.builder();
						return newPartyElection;
					});
		}
		
		@Override
		@RosettaAttribute("custodianEvent")
		public CustodianEvent.CustodianEventBuilder getCustodianEvent() {
			return custodianEvent;
		}
		
		@Override
		public CustodianEvent.CustodianEventBuilder getOrCreateCustodianEvent() {
			CustodianEvent.CustodianEventBuilder result;
			if (custodianEvent!=null) {
				result = custodianEvent;
			}
			else {
				result = custodianEvent = CustodianEvent.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("isCreditSupportDocument")
		public Boolean getIsCreditSupportDocument() {
			return isCreditSupportDocument;
		}
		
		@Override
		@RosettaAttribute("hasControlAgreementLanguage")
		public Boolean getHasControlAgreementLanguage() {
			return hasControlAgreementLanguage;
		}
		
		@Override
		@RosettaAttribute("otherProvisions")
		public String getOtherProvisions() {
			return otherProvisions;
		}
		
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder addPartyElection(CustodyArrangementsElection partyElection) {
			if (partyElection!=null) this.partyElection.add(partyElection.toBuilder());
			return this;
		}
		
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder addPartyElection(CustodyArrangementsElection partyElection, int _idx) {
			getIndex(this.partyElection, _idx, () -> partyElection.toBuilder());
			return this;
		}
		@Override 
		public CustodyArrangements.CustodyArrangementsBuilder addPartyElection(List partyElections) {
			if (partyElections != null) {
				for (CustodyArrangementsElection toAdd : partyElections) {
					this.partyElection.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("partyElection")
		public CustodyArrangements.CustodyArrangementsBuilder setPartyElection(List partyElections) {
			if (partyElections == null)  {
				this.partyElection = new ArrayList<>();
			}
			else {
				this.partyElection = partyElections.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		@RosettaAttribute("custodianEvent")
		public CustodyArrangements.CustodyArrangementsBuilder setCustodianEvent(CustodianEvent custodianEvent) {
			this.custodianEvent = custodianEvent==null?null:custodianEvent.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("isCreditSupportDocument")
		public CustodyArrangements.CustodyArrangementsBuilder setIsCreditSupportDocument(Boolean isCreditSupportDocument) {
			this.isCreditSupportDocument = isCreditSupportDocument==null?null:isCreditSupportDocument;
			return this;
		}
		@Override
		@RosettaAttribute("hasControlAgreementLanguage")
		public CustodyArrangements.CustodyArrangementsBuilder setHasControlAgreementLanguage(Boolean hasControlAgreementLanguage) {
			this.hasControlAgreementLanguage = hasControlAgreementLanguage==null?null:hasControlAgreementLanguage;
			return this;
		}
		@Override
		@RosettaAttribute("otherProvisions")
		public CustodyArrangements.CustodyArrangementsBuilder setOtherProvisions(String otherProvisions) {
			this.otherProvisions = otherProvisions==null?null:otherProvisions;
			return this;
		}
		
		@Override
		public CustodyArrangements build() {
			return new CustodyArrangements.CustodyArrangementsImpl(this);
		}
		
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder prune() {
			partyElection = partyElection.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			if (custodianEvent!=null && !custodianEvent.prune().hasData()) custodianEvent = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPartyElection()!=null && getPartyElection().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			if (getCustodianEvent()!=null && getCustodianEvent().hasData()) return true;
			if (getIsCreditSupportDocument()!=null) return true;
			if (getHasControlAgreementLanguage()!=null) return true;
			if (getOtherProvisions()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public CustodyArrangements.CustodyArrangementsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			CustodyArrangements.CustodyArrangementsBuilder o = (CustodyArrangements.CustodyArrangementsBuilder) other;
			
			merger.mergeRosetta(getPartyElection(), o.getPartyElection(), this::getOrCreatePartyElection);
			merger.mergeRosetta(getCustodianEvent(), o.getCustodianEvent(), this::setCustodianEvent);
			
			merger.mergeBasic(getIsCreditSupportDocument(), o.getIsCreditSupportDocument(), this::setIsCreditSupportDocument);
			merger.mergeBasic(getHasControlAgreementLanguage(), o.getHasControlAgreementLanguage(), this::setHasControlAgreementLanguage);
			merger.mergeBasic(getOtherProvisions(), o.getOtherProvisions(), this::setOtherProvisions);
			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;
		
			CustodyArrangements _that = getType().cast(o);
		
			if (!ListEquals.listEquals(partyElection, _that.getPartyElection())) return false;
			if (!Objects.equals(custodianEvent, _that.getCustodianEvent())) return false;
			if (!Objects.equals(isCreditSupportDocument, _that.getIsCreditSupportDocument())) return false;
			if (!Objects.equals(hasControlAgreementLanguage, _that.getHasControlAgreementLanguage())) return false;
			if (!Objects.equals(otherProvisions, _that.getOtherProvisions())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
			_result = 31 * _result + (custodianEvent != null ? custodianEvent.hashCode() : 0);
			_result = 31 * _result + (isCreditSupportDocument != null ? isCreditSupportDocument.hashCode() : 0);
			_result = 31 * _result + (hasControlAgreementLanguage != null ? hasControlAgreementLanguage.hashCode() : 0);
			_result = 31 * _result + (otherProvisions != null ? otherProvisions.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "CustodyArrangementsBuilder {" +
				"partyElection=" + this.partyElection + ", " +
				"custodianEvent=" + this.custodianEvent + ", " +
				"isCreditSupportDocument=" + this.isCreditSupportDocument + ", " +
				"hasControlAgreementLanguage=" + this.hasControlAgreementLanguage + ", " +
				"otherProvisions=" + this.otherProvisions +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy