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

com.rosetta.metatest.model.Top10 Maven / Gradle / Ivy

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

import com.rosetta.metatest.model.PriceQuantity;
import com.rosetta.metatest.model.ResolvablePayoutQuantity;
import com.rosetta.metatest.model.Top10;
import com.rosetta.metatest.model.Top10.Top10Builder;
import com.rosetta.metatest.model.Top10.Top10BuilderImpl;
import com.rosetta.metatest.model.Top10.Top10Impl;
import com.rosetta.metatest.model.meta.Top10Meta;
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="Top10", builder=Top10.Top10BuilderImpl.class, version="test")
public interface Top10 extends RosettaModelObject {

	Top10Meta metaData = new Top10Meta();

	/*********************** Getter Methods  ***********************/
	PriceQuantity getPq();
	ResolvablePayoutQuantity getRpq();

	/*********************** Build Methods  ***********************/
	Top10 build();
	
	Top10.Top10Builder toBuilder();
	
	static Top10.Top10Builder builder() {
		return new Top10.Top10BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Top10.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("pq"), processor, PriceQuantity.class, getPq());
		processRosetta(path.newSubPath("rpq"), processor, ResolvablePayoutQuantity.class, getRpq());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Top10Builder extends Top10, RosettaModelObjectBuilder {
		PriceQuantity.PriceQuantityBuilder getOrCreatePq();
		PriceQuantity.PriceQuantityBuilder getPq();
		ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder getOrCreateRpq();
		ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder getRpq();
		Top10.Top10Builder setPq(PriceQuantity pq);
		Top10.Top10Builder setRpq(ResolvablePayoutQuantity rpq);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("pq"), processor, PriceQuantity.PriceQuantityBuilder.class, getPq());
			processRosetta(path.newSubPath("rpq"), processor, ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder.class, getRpq());
		}
		

		Top10.Top10Builder prune();
	}

	/*********************** Immutable Implementation of Top10  ***********************/
	class Top10Impl implements Top10 {
		private final PriceQuantity pq;
		private final ResolvablePayoutQuantity rpq;
		
		protected Top10Impl(Top10.Top10Builder builder) {
			this.pq = ofNullable(builder.getPq()).map(f->f.build()).orElse(null);
			this.rpq = ofNullable(builder.getRpq()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("pq")
		public PriceQuantity getPq() {
			return pq;
		}
		
		@Override
		@RosettaAttribute("rpq")
		public ResolvablePayoutQuantity getRpq() {
			return rpq;
		}
		
		@Override
		public Top10 build() {
			return this;
		}
		
		@Override
		public Top10.Top10Builder toBuilder() {
			Top10.Top10Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Top10.Top10Builder builder) {
			ofNullable(getPq()).ifPresent(builder::setPq);
			ofNullable(getRpq()).ifPresent(builder::setRpq);
		}

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

	/*********************** Builder Implementation of Top10  ***********************/
	class Top10BuilderImpl implements Top10.Top10Builder {
	
		protected PriceQuantity.PriceQuantityBuilder pq;
		protected ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder rpq;
	
		public Top10BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("pq")
		public PriceQuantity.PriceQuantityBuilder getPq() {
			return pq;
		}
		
		@Override
		public PriceQuantity.PriceQuantityBuilder getOrCreatePq() {
			PriceQuantity.PriceQuantityBuilder result;
			if (pq!=null) {
				result = pq;
			}
			else {
				result = pq = PriceQuantity.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("rpq")
		public ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder getRpq() {
			return rpq;
		}
		
		@Override
		public ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder getOrCreateRpq() {
			ResolvablePayoutQuantity.ResolvablePayoutQuantityBuilder result;
			if (rpq!=null) {
				result = rpq;
			}
			else {
				result = rpq = ResolvablePayoutQuantity.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("pq")
		public Top10.Top10Builder setPq(PriceQuantity pq) {
			this.pq = pq==null?null:pq.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("rpq")
		public Top10.Top10Builder setRpq(ResolvablePayoutQuantity rpq) {
			this.rpq = rpq==null?null:rpq.toBuilder();
			return this;
		}
		
		@Override
		public Top10 build() {
			return new Top10.Top10Impl(this);
		}
		
		@Override
		public Top10.Top10Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top10.Top10Builder prune() {
			if (pq!=null && !pq.prune().hasData()) pq = null;
			if (rpq!=null && !rpq.prune().hasData()) rpq = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPq()!=null && getPq().hasData()) return true;
			if (getRpq()!=null && getRpq().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top10.Top10Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Top10.Top10Builder o = (Top10.Top10Builder) other;
			
			merger.mergeRosetta(getPq(), o.getPq(), this::setPq);
			merger.mergeRosetta(getRpq(), o.getRpq(), this::setRpq);
			
			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;
		
			Top10 _that = getType().cast(o);
		
			if (!Objects.equals(pq, _that.getPq())) return false;
			if (!Objects.equals(rpq, _that.getRpq())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (pq != null ? pq.hashCode() : 0);
			_result = 31 * _result + (rpq != null ? rpq.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Top10Builder {" +
				"pq=" + this.pq + ", " +
				"rpq=" + this.rpq +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy