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

com.rosetta.testother.model.Quote Maven / Gradle / Ivy

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

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.testother.model.Quote;
import com.rosetta.testother.model.Quote.QuoteBuilder;
import com.rosetta.testother.model.Quote.QuoteBuilderImpl;
import com.rosetta.testother.model.Quote.QuoteImpl;
import com.rosetta.testother.model.QuoteBasisEnum;
import com.rosetta.testother.model.meta.QuoteMeta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	QuoteMeta metaData = new QuoteMeta();

	/*********************** Getter Methods  ***********************/
	QuoteBasisEnum getQuoteBasis();

	/*********************** Build Methods  ***********************/
	Quote build();
	
	Quote.QuoteBuilder toBuilder();
	
	static Quote.QuoteBuilder builder() {
		return new Quote.QuoteBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Quote.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("quoteBasis"), QuoteBasisEnum.class, getQuoteBasis(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface QuoteBuilder extends Quote, RosettaModelObjectBuilder {
		Quote.QuoteBuilder setQuoteBasis(QuoteBasisEnum quoteBasis);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("quoteBasis"), QuoteBasisEnum.class, getQuoteBasis(), this);
		}
		

		Quote.QuoteBuilder prune();
	}

	/*********************** Immutable Implementation of Quote  ***********************/
	class QuoteImpl implements Quote {
		private final QuoteBasisEnum quoteBasis;
		
		protected QuoteImpl(Quote.QuoteBuilder builder) {
			this.quoteBasis = builder.getQuoteBasis();
		}
		
		@Override
		@RosettaAttribute("quoteBasis")
		public QuoteBasisEnum getQuoteBasis() {
			return quoteBasis;
		}
		
		@Override
		public Quote build() {
			return this;
		}
		
		@Override
		public Quote.QuoteBuilder toBuilder() {
			Quote.QuoteBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Quote.QuoteBuilder builder) {
			ofNullable(getQuoteBasis()).ifPresent(builder::setQuoteBasis);
		}

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

	/*********************** Builder Implementation of Quote  ***********************/
	class QuoteBuilderImpl implements Quote.QuoteBuilder {
	
		protected QuoteBasisEnum quoteBasis;
	
		public QuoteBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("quoteBasis")
		public QuoteBasisEnum getQuoteBasis() {
			return quoteBasis;
		}
		
		@Override
		@RosettaAttribute("quoteBasis")
		public Quote.QuoteBuilder setQuoteBasis(QuoteBasisEnum quoteBasis) {
			this.quoteBasis = quoteBasis==null?null:quoteBasis;
			return this;
		}
		
		@Override
		public Quote build() {
			return new Quote.QuoteImpl(this);
		}
		
		@Override
		public Quote.QuoteBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Quote.QuoteBuilder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getQuoteBasis()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Quote.QuoteBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Quote.QuoteBuilder o = (Quote.QuoteBuilder) other;
			
			
			merger.mergeBasic(getQuoteBasis(), o.getQuoteBasis(), this::setQuoteBasis);
			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;
		
			Quote _that = getType().cast(o);
		
			if (!Objects.equals(quoteBasis, _that.getQuoteBasis())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (quoteBasis != null ? quoteBasis.getClass().getName().hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "QuoteBuilder {" +
				"quoteBasis=" + this.quoteBasis +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy