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

com.rosetta.jptlegalagreement.model.MultipleCreditNotations 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.MultipleCreditNotations;
import com.rosetta.jptlegalagreement.model.MultipleCreditNotations.MultipleCreditNotationsBuilder;
import com.rosetta.jptlegalagreement.model.MultipleCreditNotations.MultipleCreditNotationsBuilderImpl;
import com.rosetta.jptlegalagreement.model.MultipleCreditNotations.MultipleCreditNotationsImpl;
import com.rosetta.jptlegalagreement.model.QuantifierEnum;
import com.rosetta.jptlegalagreement.model.meta.MultipleCreditNotationsMeta;
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.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
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="MultipleCreditNotations", builder=MultipleCreditNotations.MultipleCreditNotationsBuilderImpl.class, version="test")
public interface MultipleCreditNotations extends RosettaModelObject {

	MultipleCreditNotationsMeta metaData = new MultipleCreditNotationsMeta();

	/*********************** Getter Methods  ***********************/
	QuantifierEnum getCondition();
	List getCreditNotation();

	/*********************** Build Methods  ***********************/
	MultipleCreditNotations build();
	
	MultipleCreditNotations.MultipleCreditNotationsBuilder toBuilder();
	
	static MultipleCreditNotations.MultipleCreditNotationsBuilder builder() {
		return new MultipleCreditNotations.MultipleCreditNotationsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return MultipleCreditNotations.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("condition"), QuantifierEnum.class, getCondition(), this);
		processRosetta(path.newSubPath("creditNotation"), processor, FieldWithMetaString.class, getCreditNotation());
	}
	

	/*********************** Builder Interface  ***********************/
	interface MultipleCreditNotationsBuilder extends MultipleCreditNotations, RosettaModelObjectBuilder {
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateCreditNotation(int _index);
		List getCreditNotation();
		MultipleCreditNotations.MultipleCreditNotationsBuilder setCondition(QuantifierEnum condition);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(FieldWithMetaString creditNotation0);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(FieldWithMetaString creditNotation1, int _idx);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(String creditNotation2);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(String creditNotation3, int _idx);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(List creditNotation4);
		MultipleCreditNotations.MultipleCreditNotationsBuilder setCreditNotation(List creditNotation5);
		MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(List creditNotation6);
		MultipleCreditNotations.MultipleCreditNotationsBuilder setCreditNotationValue(List creditNotation7);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("condition"), QuantifierEnum.class, getCondition(), this);
			processRosetta(path.newSubPath("creditNotation"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getCreditNotation());
		}
		

		MultipleCreditNotations.MultipleCreditNotationsBuilder prune();
	}

	/*********************** Immutable Implementation of MultipleCreditNotations  ***********************/
	class MultipleCreditNotationsImpl implements MultipleCreditNotations {
		private final QuantifierEnum condition;
		private final List creditNotation;
		
		protected MultipleCreditNotationsImpl(MultipleCreditNotations.MultipleCreditNotationsBuilder builder) {
			this.condition = builder.getCondition();
			this.creditNotation = ofNullable(builder.getCreditNotation()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
		}
		
		@Override
		@RosettaAttribute("condition")
		public QuantifierEnum getCondition() {
			return condition;
		}
		
		@Override
		@RosettaAttribute("creditNotation")
		public List getCreditNotation() {
			return creditNotation;
		}
		
		@Override
		public MultipleCreditNotations build() {
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder toBuilder() {
			MultipleCreditNotations.MultipleCreditNotationsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(MultipleCreditNotations.MultipleCreditNotationsBuilder builder) {
			ofNullable(getCondition()).ifPresent(builder::setCondition);
			ofNullable(getCreditNotation()).ifPresent(builder::setCreditNotation);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			MultipleCreditNotations _that = getType().cast(o);
		
			if (!Objects.equals(condition, _that.getCondition())) return false;
			if (!ListEquals.listEquals(creditNotation, _that.getCreditNotation())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (condition != null ? condition.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (creditNotation != null ? creditNotation.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "MultipleCreditNotations {" +
				"condition=" + this.condition + ", " +
				"creditNotation=" + this.creditNotation +
			'}';
		}
	}

	/*********************** Builder Implementation of MultipleCreditNotations  ***********************/
	class MultipleCreditNotationsBuilderImpl implements MultipleCreditNotations.MultipleCreditNotationsBuilder {
	
		protected QuantifierEnum condition;
		protected List creditNotation = new ArrayList<>();
	
		public MultipleCreditNotationsBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("condition")
		public QuantifierEnum getCondition() {
			return condition;
		}
		
		@Override
		@RosettaAttribute("creditNotation")
		public List getCreditNotation() {
			return creditNotation;
		}
		
		public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateCreditNotation(int _index) {
		
			if (creditNotation==null) {
				this.creditNotation = new ArrayList<>();
			}
			FieldWithMetaString.FieldWithMetaStringBuilder result;
			return getIndex(creditNotation, _index, () -> {
						FieldWithMetaString.FieldWithMetaStringBuilder newCreditNotation = FieldWithMetaString.builder();
						return newCreditNotation;
					});
		}
		
		@Override
		@RosettaAttribute("condition")
		public MultipleCreditNotations.MultipleCreditNotationsBuilder setCondition(QuantifierEnum condition) {
			this.condition = condition==null?null:condition;
			return this;
		}
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(FieldWithMetaString creditNotation) {
			if (creditNotation!=null) this.creditNotation.add(creditNotation.toBuilder());
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(FieldWithMetaString creditNotation, int _idx) {
			getIndex(this.creditNotation, _idx, () -> creditNotation.toBuilder());
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(String creditNotation) {
			this.getOrCreateCreditNotation(-1).setValue(creditNotation);
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(String creditNotation, int _idx) {
			this.getOrCreateCreditNotation(_idx).setValue(creditNotation);
			return this;
		}
		@Override 
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotation(List creditNotations) {
			if (creditNotations != null) {
				for (FieldWithMetaString toAdd : creditNotations) {
					this.creditNotation.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("creditNotation")
		public MultipleCreditNotations.MultipleCreditNotationsBuilder setCreditNotation(List creditNotations) {
			if (creditNotations == null)  {
				this.creditNotation = new ArrayList<>();
			}
			else {
				this.creditNotation = creditNotations.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder addCreditNotationValue(List creditNotations) {
			if (creditNotations != null) {
				for (String toAdd : creditNotations) {
					this.addCreditNotationValue(toAdd);
				}
			}
			return this;
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder setCreditNotationValue(List creditNotations) {
			this.creditNotation.clear();
			if (creditNotations!=null) {
				creditNotations.forEach(this::addCreditNotationValue);
			}
			return this;
		}
		
		
		@Override
		public MultipleCreditNotations build() {
			return new MultipleCreditNotations.MultipleCreditNotationsImpl(this);
		}
		
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder prune() {
			creditNotation = creditNotation.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getCondition()!=null) return true;
			if (getCreditNotation()!=null && !getCreditNotation().isEmpty()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public MultipleCreditNotations.MultipleCreditNotationsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			MultipleCreditNotations.MultipleCreditNotationsBuilder o = (MultipleCreditNotations.MultipleCreditNotationsBuilder) other;
			
			merger.mergeRosetta(getCreditNotation(), o.getCreditNotation(), this::getOrCreateCreditNotation);
			
			merger.mergeBasic(getCondition(), o.getCondition(), this::setCondition);
			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;
		
			MultipleCreditNotations _that = getType().cast(o);
		
			if (!Objects.equals(condition, _that.getCondition())) return false;
			if (!ListEquals.listEquals(creditNotation, _that.getCreditNotation())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (condition != null ? condition.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (creditNotation != null ? creditNotation.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "MultipleCreditNotationsBuilder {" +
				"condition=" + this.condition + ", " +
				"creditNotation=" + this.creditNotation +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy