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

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

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

import com.rosetta.jptlegalagreement.model.OneWayProvisions;
import com.rosetta.jptlegalagreement.model.OneWayProvisions.OneWayProvisionsBuilder;
import com.rosetta.jptlegalagreement.model.OneWayProvisions.OneWayProvisionsBuilderImpl;
import com.rosetta.jptlegalagreement.model.OneWayProvisions.OneWayProvisionsImpl;
import com.rosetta.jptlegalagreement.model.Party;
import com.rosetta.jptlegalagreement.model.meta.OneWayProvisionsMeta;
import com.rosetta.jptlegalagreement.model.metafields.ReferenceWithMetaParty;
import com.rosetta.jptlegalagreement.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="OneWayProvisions", builder=OneWayProvisions.OneWayProvisionsBuilderImpl.class, version="test")
public interface OneWayProvisions extends RosettaModelObject {

	OneWayProvisionsMeta metaData = new OneWayProvisionsMeta();

	/*********************** Getter Methods  ***********************/
	Boolean getIsApplicable();
	ReferenceWithMetaParty getPostingParty();

	/*********************** Build Methods  ***********************/
	OneWayProvisions build();
	
	OneWayProvisions.OneWayProvisionsBuilder toBuilder();
	
	static OneWayProvisions.OneWayProvisionsBuilder builder() {
		return new OneWayProvisions.OneWayProvisionsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return OneWayProvisions.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("isApplicable"), Boolean.class, getIsApplicable(), this);
		processRosetta(path.newSubPath("postingParty"), processor, ReferenceWithMetaParty.class, getPostingParty());
	}
	

	/*********************** Builder Interface  ***********************/
	interface OneWayProvisionsBuilder extends OneWayProvisions, RosettaModelObjectBuilder {
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreatePostingParty();
		ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getPostingParty();
		OneWayProvisions.OneWayProvisionsBuilder setIsApplicable(Boolean isApplicable);
		OneWayProvisions.OneWayProvisionsBuilder setPostingParty(ReferenceWithMetaParty postingParty0);
		OneWayProvisions.OneWayProvisionsBuilder setPostingPartyValue(Party postingParty1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("isApplicable"), Boolean.class, getIsApplicable(), this);
			processRosetta(path.newSubPath("postingParty"), processor, ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder.class, getPostingParty());
		}
		

		OneWayProvisions.OneWayProvisionsBuilder prune();
	}

	/*********************** Immutable Implementation of OneWayProvisions  ***********************/
	class OneWayProvisionsImpl implements OneWayProvisions {
		private final Boolean isApplicable;
		private final ReferenceWithMetaParty postingParty;
		
		protected OneWayProvisionsImpl(OneWayProvisions.OneWayProvisionsBuilder builder) {
			this.isApplicable = builder.getIsApplicable();
			this.postingParty = ofNullable(builder.getPostingParty()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("isApplicable")
		public Boolean getIsApplicable() {
			return isApplicable;
		}
		
		@Override
		@RosettaAttribute("postingParty")
		public ReferenceWithMetaParty getPostingParty() {
			return postingParty;
		}
		
		@Override
		public OneWayProvisions build() {
			return this;
		}
		
		@Override
		public OneWayProvisions.OneWayProvisionsBuilder toBuilder() {
			OneWayProvisions.OneWayProvisionsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(OneWayProvisions.OneWayProvisionsBuilder builder) {
			ofNullable(getIsApplicable()).ifPresent(builder::setIsApplicable);
			ofNullable(getPostingParty()).ifPresent(builder::setPostingParty);
		}

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

	/*********************** Builder Implementation of OneWayProvisions  ***********************/
	class OneWayProvisionsBuilderImpl implements OneWayProvisions.OneWayProvisionsBuilder {
	
		protected Boolean isApplicable;
		protected ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder postingParty;
	
		public OneWayProvisionsBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("isApplicable")
		public Boolean getIsApplicable() {
			return isApplicable;
		}
		
		@Override
		@RosettaAttribute("postingParty")
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getPostingParty() {
			return postingParty;
		}
		
		@Override
		public ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder getOrCreatePostingParty() {
			ReferenceWithMetaParty.ReferenceWithMetaPartyBuilder result;
			if (postingParty!=null) {
				result = postingParty;
			}
			else {
				result = postingParty = ReferenceWithMetaParty.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("isApplicable")
		public OneWayProvisions.OneWayProvisionsBuilder setIsApplicable(Boolean isApplicable) {
			this.isApplicable = isApplicable==null?null:isApplicable;
			return this;
		}
		@Override
		@RosettaAttribute("postingParty")
		public OneWayProvisions.OneWayProvisionsBuilder setPostingParty(ReferenceWithMetaParty postingParty) {
			this.postingParty = postingParty==null?null:postingParty.toBuilder();
			return this;
		}
		@Override
		public OneWayProvisions.OneWayProvisionsBuilder setPostingPartyValue(Party postingParty) {
			this.getOrCreatePostingParty().setValue(postingParty);
			return this;
		}
		
		@Override
		public OneWayProvisions build() {
			return new OneWayProvisions.OneWayProvisionsImpl(this);
		}
		
		@Override
		public OneWayProvisions.OneWayProvisionsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public OneWayProvisions.OneWayProvisionsBuilder prune() {
			if (postingParty!=null && !postingParty.prune().hasData()) postingParty = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getIsApplicable()!=null) return true;
			if (getPostingParty()!=null && getPostingParty().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public OneWayProvisions.OneWayProvisionsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			OneWayProvisions.OneWayProvisionsBuilder o = (OneWayProvisions.OneWayProvisionsBuilder) other;
			
			merger.mergeRosetta(getPostingParty(), o.getPostingParty(), this::setPostingParty);
			
			merger.mergeBasic(getIsApplicable(), o.getIsApplicable(), this::setIsApplicable);
			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;
		
			OneWayProvisions _that = getType().cast(o);
		
			if (!Objects.equals(isApplicable, _that.getIsApplicable())) return false;
			if (!Objects.equals(postingParty, _that.getPostingParty())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (isApplicable != null ? isApplicable.hashCode() : 0);
			_result = 31 * _result + (postingParty != null ? postingParty.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "OneWayProvisionsBuilder {" +
				"isApplicable=" + this.isApplicable + ", " +
				"postingParty=" + this.postingParty +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy