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

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

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

import com.rosetta.jptlegalagreement.model.CreditNotation;
import com.rosetta.jptlegalagreement.model.CreditNotation.CreditNotationBuilder;
import com.rosetta.jptlegalagreement.model.CreditNotation.CreditNotationBuilderImpl;
import com.rosetta.jptlegalagreement.model.CreditNotation.CreditNotationImpl;
import com.rosetta.jptlegalagreement.model.CreditRatingAgencyEnum;
import com.rosetta.jptlegalagreement.model.meta.CreditNotationMeta;
import com.rosetta.jptlegalagreement.model.metafields.FieldWithMetaCreditRatingAgencyEnum;
import com.rosetta.jptlegalagreement.model.metafields.FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder;
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 java.util.Objects;

import static java.util.Optional.ofNullable;

/**
 * @version test
 */
@RosettaDataType(value="CreditNotation", builder=CreditNotation.CreditNotationBuilderImpl.class, version="test")
public interface CreditNotation extends RosettaModelObject {

	CreditNotationMeta metaData = new CreditNotationMeta();

	/*********************** Getter Methods  ***********************/
	FieldWithMetaCreditRatingAgencyEnum getAgency();
	FieldWithMetaString getNotation();
	FieldWithMetaString getScale();

	/*********************** Build Methods  ***********************/
	CreditNotation build();
	
	CreditNotation.CreditNotationBuilder toBuilder();
	
	static CreditNotation.CreditNotationBuilder builder() {
		return new CreditNotation.CreditNotationBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return CreditNotation.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("agency"), processor, FieldWithMetaCreditRatingAgencyEnum.class, getAgency());
		processRosetta(path.newSubPath("notation"), processor, FieldWithMetaString.class, getNotation());
		processRosetta(path.newSubPath("scale"), processor, FieldWithMetaString.class, getScale());
	}
	

	/*********************** Builder Interface  ***********************/
	interface CreditNotationBuilder extends CreditNotation, RosettaModelObjectBuilder {
		FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder getOrCreateAgency();
		FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder getAgency();
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateNotation();
		FieldWithMetaString.FieldWithMetaStringBuilder getNotation();
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateScale();
		FieldWithMetaString.FieldWithMetaStringBuilder getScale();
		CreditNotation.CreditNotationBuilder setAgency(FieldWithMetaCreditRatingAgencyEnum agency0);
		CreditNotation.CreditNotationBuilder setAgencyValue(CreditRatingAgencyEnum agency1);
		CreditNotation.CreditNotationBuilder setNotation(FieldWithMetaString notation0);
		CreditNotation.CreditNotationBuilder setNotationValue(String notation1);
		CreditNotation.CreditNotationBuilder setScale(FieldWithMetaString scale0);
		CreditNotation.CreditNotationBuilder setScaleValue(String scale1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("agency"), processor, FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder.class, getAgency());
			processRosetta(path.newSubPath("notation"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getNotation());
			processRosetta(path.newSubPath("scale"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getScale());
		}
		

		CreditNotation.CreditNotationBuilder prune();
	}

	/*********************** Immutable Implementation of CreditNotation  ***********************/
	class CreditNotationImpl implements CreditNotation {
		private final FieldWithMetaCreditRatingAgencyEnum agency;
		private final FieldWithMetaString notation;
		private final FieldWithMetaString scale;
		
		protected CreditNotationImpl(CreditNotation.CreditNotationBuilder builder) {
			this.agency = ofNullable(builder.getAgency()).map(f->f.build()).orElse(null);
			this.notation = ofNullable(builder.getNotation()).map(f->f.build()).orElse(null);
			this.scale = ofNullable(builder.getScale()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("agency")
		public FieldWithMetaCreditRatingAgencyEnum getAgency() {
			return agency;
		}
		
		@Override
		@RosettaAttribute("notation")
		public FieldWithMetaString getNotation() {
			return notation;
		}
		
		@Override
		@RosettaAttribute("scale")
		public FieldWithMetaString getScale() {
			return scale;
		}
		
		@Override
		public CreditNotation build() {
			return this;
		}
		
		@Override
		public CreditNotation.CreditNotationBuilder toBuilder() {
			CreditNotation.CreditNotationBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(CreditNotation.CreditNotationBuilder builder) {
			ofNullable(getAgency()).ifPresent(builder::setAgency);
			ofNullable(getNotation()).ifPresent(builder::setNotation);
			ofNullable(getScale()).ifPresent(builder::setScale);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			CreditNotation _that = getType().cast(o);
		
			if (!Objects.equals(agency, _that.getAgency())) return false;
			if (!Objects.equals(notation, _that.getNotation())) return false;
			if (!Objects.equals(scale, _that.getScale())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (agency != null ? agency.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (notation != null ? notation.hashCode() : 0);
			_result = 31 * _result + (scale != null ? scale.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "CreditNotation {" +
				"agency=" + this.agency + ", " +
				"notation=" + this.notation + ", " +
				"scale=" + this.scale +
			'}';
		}
	}

	/*********************** Builder Implementation of CreditNotation  ***********************/
	class CreditNotationBuilderImpl implements CreditNotation.CreditNotationBuilder {
	
		protected FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder agency;
		protected FieldWithMetaString.FieldWithMetaStringBuilder notation;
		protected FieldWithMetaString.FieldWithMetaStringBuilder scale;
	
		public CreditNotationBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("agency")
		public FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder getAgency() {
			return agency;
		}
		
		@Override
		public FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder getOrCreateAgency() {
			FieldWithMetaCreditRatingAgencyEnum.FieldWithMetaCreditRatingAgencyEnumBuilder result;
			if (agency!=null) {
				result = agency;
			}
			else {
				result = agency = FieldWithMetaCreditRatingAgencyEnum.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("notation")
		public FieldWithMetaString.FieldWithMetaStringBuilder getNotation() {
			return notation;
		}
		
		@Override
		public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateNotation() {
			FieldWithMetaString.FieldWithMetaStringBuilder result;
			if (notation!=null) {
				result = notation;
			}
			else {
				result = notation = FieldWithMetaString.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("scale")
		public FieldWithMetaString.FieldWithMetaStringBuilder getScale() {
			return scale;
		}
		
		@Override
		public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateScale() {
			FieldWithMetaString.FieldWithMetaStringBuilder result;
			if (scale!=null) {
				result = scale;
			}
			else {
				result = scale = FieldWithMetaString.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("agency")
		public CreditNotation.CreditNotationBuilder setAgency(FieldWithMetaCreditRatingAgencyEnum agency) {
			this.agency = agency==null?null:agency.toBuilder();
			return this;
		}
		@Override
		public CreditNotation.CreditNotationBuilder setAgencyValue(CreditRatingAgencyEnum agency) {
			this.getOrCreateAgency().setValue(agency);
			return this;
		}
		@Override
		@RosettaAttribute("notation")
		public CreditNotation.CreditNotationBuilder setNotation(FieldWithMetaString notation) {
			this.notation = notation==null?null:notation.toBuilder();
			return this;
		}
		@Override
		public CreditNotation.CreditNotationBuilder setNotationValue(String notation) {
			this.getOrCreateNotation().setValue(notation);
			return this;
		}
		@Override
		@RosettaAttribute("scale")
		public CreditNotation.CreditNotationBuilder setScale(FieldWithMetaString scale) {
			this.scale = scale==null?null:scale.toBuilder();
			return this;
		}
		@Override
		public CreditNotation.CreditNotationBuilder setScaleValue(String scale) {
			this.getOrCreateScale().setValue(scale);
			return this;
		}
		
		@Override
		public CreditNotation build() {
			return new CreditNotation.CreditNotationImpl(this);
		}
		
		@Override
		public CreditNotation.CreditNotationBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public CreditNotation.CreditNotationBuilder prune() {
			if (agency!=null && !agency.prune().hasData()) agency = null;
			if (notation!=null && !notation.prune().hasData()) notation = null;
			if (scale!=null && !scale.prune().hasData()) scale = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getAgency()!=null) return true;
			if (getNotation()!=null) return true;
			if (getScale()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public CreditNotation.CreditNotationBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			CreditNotation.CreditNotationBuilder o = (CreditNotation.CreditNotationBuilder) other;
			
			merger.mergeRosetta(getAgency(), o.getAgency(), this::setAgency);
			merger.mergeRosetta(getNotation(), o.getNotation(), this::setNotation);
			merger.mergeRosetta(getScale(), o.getScale(), this::setScale);
			
			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;
		
			CreditNotation _that = getType().cast(o);
		
			if (!Objects.equals(agency, _that.getAgency())) return false;
			if (!Objects.equals(notation, _that.getNotation())) return false;
			if (!Objects.equals(scale, _that.getScale())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (agency != null ? agency.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (notation != null ? notation.hashCode() : 0);
			_result = 31 * _result + (scale != null ? scale.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "CreditNotationBuilder {" +
				"agency=" + this.agency + ", " +
				"notation=" + this.notation + ", " +
				"scale=" + this.scale +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy