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

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

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

import com.rosetta.jptlegalagreement.model.Substitution;
import com.rosetta.jptlegalagreement.model.Substitution.SubstitutionBuilder;
import com.rosetta.jptlegalagreement.model.Substitution.SubstitutionBuilderImpl;
import com.rosetta.jptlegalagreement.model.Substitution.SubstitutionImpl;
import com.rosetta.jptlegalagreement.model.meta.SubstitutionMeta;
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="Substitution", builder=Substitution.SubstitutionBuilderImpl.class, version="test")
public interface Substitution extends RosettaModelObject {

	SubstitutionMeta metaData = new SubstitutionMeta();

	/*********************** Getter Methods  ***********************/
	Boolean getNeedsConsent();
	String getSpecificConsentLanguage();

	/*********************** Build Methods  ***********************/
	Substitution build();
	
	Substitution.SubstitutionBuilder toBuilder();
	
	static Substitution.SubstitutionBuilder builder() {
		return new Substitution.SubstitutionBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Substitution.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("needsConsent"), Boolean.class, getNeedsConsent(), this);
		processor.processBasic(path.newSubPath("specificConsentLanguage"), String.class, getSpecificConsentLanguage(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface SubstitutionBuilder extends Substitution, RosettaModelObjectBuilder {
		Substitution.SubstitutionBuilder setNeedsConsent(Boolean needsConsent);
		Substitution.SubstitutionBuilder setSpecificConsentLanguage(String specificConsentLanguage);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("needsConsent"), Boolean.class, getNeedsConsent(), this);
			processor.processBasic(path.newSubPath("specificConsentLanguage"), String.class, getSpecificConsentLanguage(), this);
		}
		

		Substitution.SubstitutionBuilder prune();
	}

	/*********************** Immutable Implementation of Substitution  ***********************/
	class SubstitutionImpl implements Substitution {
		private final Boolean needsConsent;
		private final String specificConsentLanguage;
		
		protected SubstitutionImpl(Substitution.SubstitutionBuilder builder) {
			this.needsConsent = builder.getNeedsConsent();
			this.specificConsentLanguage = builder.getSpecificConsentLanguage();
		}
		
		@Override
		@RosettaAttribute("needsConsent")
		public Boolean getNeedsConsent() {
			return needsConsent;
		}
		
		@Override
		@RosettaAttribute("specificConsentLanguage")
		public String getSpecificConsentLanguage() {
			return specificConsentLanguage;
		}
		
		@Override
		public Substitution build() {
			return this;
		}
		
		@Override
		public Substitution.SubstitutionBuilder toBuilder() {
			Substitution.SubstitutionBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Substitution.SubstitutionBuilder builder) {
			ofNullable(getNeedsConsent()).ifPresent(builder::setNeedsConsent);
			ofNullable(getSpecificConsentLanguage()).ifPresent(builder::setSpecificConsentLanguage);
		}

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

	/*********************** Builder Implementation of Substitution  ***********************/
	class SubstitutionBuilderImpl implements Substitution.SubstitutionBuilder {
	
		protected Boolean needsConsent;
		protected String specificConsentLanguage;
	
		public SubstitutionBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("needsConsent")
		public Boolean getNeedsConsent() {
			return needsConsent;
		}
		
		@Override
		@RosettaAttribute("specificConsentLanguage")
		public String getSpecificConsentLanguage() {
			return specificConsentLanguage;
		}
		
		@Override
		@RosettaAttribute("needsConsent")
		public Substitution.SubstitutionBuilder setNeedsConsent(Boolean needsConsent) {
			this.needsConsent = needsConsent==null?null:needsConsent;
			return this;
		}
		@Override
		@RosettaAttribute("specificConsentLanguage")
		public Substitution.SubstitutionBuilder setSpecificConsentLanguage(String specificConsentLanguage) {
			this.specificConsentLanguage = specificConsentLanguage==null?null:specificConsentLanguage;
			return this;
		}
		
		@Override
		public Substitution build() {
			return new Substitution.SubstitutionImpl(this);
		}
		
		@Override
		public Substitution.SubstitutionBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Substitution.SubstitutionBuilder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getNeedsConsent()!=null) return true;
			if (getSpecificConsentLanguage()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Substitution.SubstitutionBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Substitution.SubstitutionBuilder o = (Substitution.SubstitutionBuilder) other;
			
			
			merger.mergeBasic(getNeedsConsent(), o.getNeedsConsent(), this::setNeedsConsent);
			merger.mergeBasic(getSpecificConsentLanguage(), o.getSpecificConsentLanguage(), this::setSpecificConsentLanguage);
			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;
		
			Substitution _that = getType().cast(o);
		
			if (!Objects.equals(needsConsent, _that.getNeedsConsent())) return false;
			if (!Objects.equals(specificConsentLanguage, _that.getSpecificConsentLanguage())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (needsConsent != null ? needsConsent.hashCode() : 0);
			_result = 31 * _result + (specificConsentLanguage != null ? specificConsentLanguage.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "SubstitutionBuilder {" +
				"needsConsent=" + this.needsConsent + ", " +
				"specificConsentLanguage=" + this.specificConsentLanguage +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy