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

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

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

import com.rosetta.jptlegalagreement.model.AdditionalRepresentation;
import com.rosetta.jptlegalagreement.model.AdditionalRepresentation.AdditionalRepresentationBuilder;
import com.rosetta.jptlegalagreement.model.AdditionalRepresentation.AdditionalRepresentationBuilderImpl;
import com.rosetta.jptlegalagreement.model.AdditionalRepresentation.AdditionalRepresentationImpl;
import com.rosetta.jptlegalagreement.model.AdditionalRepresentationElection;
import com.rosetta.jptlegalagreement.model.meta.AdditionalRepresentationMeta;
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="AdditionalRepresentation", builder=AdditionalRepresentation.AdditionalRepresentationBuilderImpl.class, version="test")
public interface AdditionalRepresentation extends RosettaModelObject {

	AdditionalRepresentationMeta metaData = new AdditionalRepresentationMeta();

	/*********************** Getter Methods  ***********************/
	AdditionalRepresentationElection getPartyElection();
	String getCustomElection();

	/*********************** Build Methods  ***********************/
	AdditionalRepresentation build();
	
	AdditionalRepresentation.AdditionalRepresentationBuilder toBuilder();
	
	static AdditionalRepresentation.AdditionalRepresentationBuilder builder() {
		return new AdditionalRepresentation.AdditionalRepresentationBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return AdditionalRepresentation.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("partyElection"), processor, AdditionalRepresentationElection.class, getPartyElection());
		processor.processBasic(path.newSubPath("customElection"), String.class, getCustomElection(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface AdditionalRepresentationBuilder extends AdditionalRepresentation, RosettaModelObjectBuilder {
		AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder getOrCreatePartyElection();
		AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder getPartyElection();
		AdditionalRepresentation.AdditionalRepresentationBuilder setPartyElection(AdditionalRepresentationElection partyElection);
		AdditionalRepresentation.AdditionalRepresentationBuilder setCustomElection(String customElection);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("partyElection"), processor, AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder.class, getPartyElection());
			processor.processBasic(path.newSubPath("customElection"), String.class, getCustomElection(), this);
		}
		

		AdditionalRepresentation.AdditionalRepresentationBuilder prune();
	}

	/*********************** Immutable Implementation of AdditionalRepresentation  ***********************/
	class AdditionalRepresentationImpl implements AdditionalRepresentation {
		private final AdditionalRepresentationElection partyElection;
		private final String customElection;
		
		protected AdditionalRepresentationImpl(AdditionalRepresentation.AdditionalRepresentationBuilder builder) {
			this.partyElection = ofNullable(builder.getPartyElection()).map(f->f.build()).orElse(null);
			this.customElection = builder.getCustomElection();
		}
		
		@Override
		@RosettaAttribute("partyElection")
		public AdditionalRepresentationElection getPartyElection() {
			return partyElection;
		}
		
		@Override
		@RosettaAttribute("customElection")
		public String getCustomElection() {
			return customElection;
		}
		
		@Override
		public AdditionalRepresentation build() {
			return this;
		}
		
		@Override
		public AdditionalRepresentation.AdditionalRepresentationBuilder toBuilder() {
			AdditionalRepresentation.AdditionalRepresentationBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(AdditionalRepresentation.AdditionalRepresentationBuilder builder) {
			ofNullable(getPartyElection()).ifPresent(builder::setPartyElection);
			ofNullable(getCustomElection()).ifPresent(builder::setCustomElection);
		}

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

	/*********************** Builder Implementation of AdditionalRepresentation  ***********************/
	class AdditionalRepresentationBuilderImpl implements AdditionalRepresentation.AdditionalRepresentationBuilder {
	
		protected AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder partyElection;
		protected String customElection;
	
		public AdditionalRepresentationBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("partyElection")
		public AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder getPartyElection() {
			return partyElection;
		}
		
		@Override
		public AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder getOrCreatePartyElection() {
			AdditionalRepresentationElection.AdditionalRepresentationElectionBuilder result;
			if (partyElection!=null) {
				result = partyElection;
			}
			else {
				result = partyElection = AdditionalRepresentationElection.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("customElection")
		public String getCustomElection() {
			return customElection;
		}
		
		@Override
		@RosettaAttribute("partyElection")
		public AdditionalRepresentation.AdditionalRepresentationBuilder setPartyElection(AdditionalRepresentationElection partyElection) {
			this.partyElection = partyElection==null?null:partyElection.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("customElection")
		public AdditionalRepresentation.AdditionalRepresentationBuilder setCustomElection(String customElection) {
			this.customElection = customElection==null?null:customElection;
			return this;
		}
		
		@Override
		public AdditionalRepresentation build() {
			return new AdditionalRepresentation.AdditionalRepresentationImpl(this);
		}
		
		@Override
		public AdditionalRepresentation.AdditionalRepresentationBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public AdditionalRepresentation.AdditionalRepresentationBuilder prune() {
			if (partyElection!=null && !partyElection.prune().hasData()) partyElection = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPartyElection()!=null && getPartyElection().hasData()) return true;
			if (getCustomElection()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public AdditionalRepresentation.AdditionalRepresentationBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			AdditionalRepresentation.AdditionalRepresentationBuilder o = (AdditionalRepresentation.AdditionalRepresentationBuilder) other;
			
			merger.mergeRosetta(getPartyElection(), o.getPartyElection(), this::setPartyElection);
			
			merger.mergeBasic(getCustomElection(), o.getCustomElection(), this::setCustomElection);
			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;
		
			AdditionalRepresentation _that = getType().cast(o);
		
			if (!Objects.equals(partyElection, _that.getPartyElection())) return false;
			if (!Objects.equals(customElection, _that.getCustomElection())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
			_result = 31 * _result + (customElection != null ? customElection.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "AdditionalRepresentationBuilder {" +
				"partyElection=" + this.partyElection + ", " +
				"customElection=" + this.customElection +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy