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

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

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

import com.rosetta.metatest.model.PriceQuantity12;
import com.rosetta.metatest.model.ResolvableAsset12;
import com.rosetta.metatest.model.Top12;
import com.rosetta.metatest.model.Top12.Top12Builder;
import com.rosetta.metatest.model.Top12.Top12BuilderImpl;
import com.rosetta.metatest.model.Top12.Top12Impl;
import com.rosetta.metatest.model.meta.Top12Meta;
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="Top12", builder=Top12.Top12BuilderImpl.class, version="test")
public interface Top12 extends RosettaModelObject {

	Top12Meta metaData = new Top12Meta();

	/*********************** Getter Methods  ***********************/
	PriceQuantity12 getPq();
	ResolvableAsset12 getRpq();

	/*********************** Build Methods  ***********************/
	Top12 build();
	
	Top12.Top12Builder toBuilder();
	
	static Top12.Top12Builder builder() {
		return new Top12.Top12BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface Top12Builder extends Top12, RosettaModelObjectBuilder {
		PriceQuantity12.PriceQuantity12Builder getOrCreatePq();
		PriceQuantity12.PriceQuantity12Builder getPq();
		ResolvableAsset12.ResolvableAsset12Builder getOrCreateRpq();
		ResolvableAsset12.ResolvableAsset12Builder getRpq();
		Top12.Top12Builder setPq(PriceQuantity12 pq);
		Top12.Top12Builder setRpq(ResolvableAsset12 rpq);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("pq"), processor, PriceQuantity12.PriceQuantity12Builder.class, getPq());
			processRosetta(path.newSubPath("rpq"), processor, ResolvableAsset12.ResolvableAsset12Builder.class, getRpq());
		}
		

		Top12.Top12Builder prune();
	}

	/*********************** Immutable Implementation of Top12  ***********************/
	class Top12Impl implements Top12 {
		private final PriceQuantity12 pq;
		private final ResolvableAsset12 rpq;
		
		protected Top12Impl(Top12.Top12Builder 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 PriceQuantity12 getPq() {
			return pq;
		}
		
		@Override
		@RosettaAttribute("rpq")
		public ResolvableAsset12 getRpq() {
			return rpq;
		}
		
		@Override
		public Top12 build() {
			return this;
		}
		
		@Override
		public Top12.Top12Builder toBuilder() {
			Top12.Top12Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Top12.Top12Builder 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;
		
			Top12 _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 "Top12 {" +
				"pq=" + this.pq + ", " +
				"rpq=" + this.rpq +
			'}';
		}
	}

	/*********************** Builder Implementation of Top12  ***********************/
	class Top12BuilderImpl implements Top12.Top12Builder {
	
		protected PriceQuantity12.PriceQuantity12Builder pq;
		protected ResolvableAsset12.ResolvableAsset12Builder rpq;
	
		public Top12BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("pq")
		public PriceQuantity12.PriceQuantity12Builder getPq() {
			return pq;
		}
		
		@Override
		public PriceQuantity12.PriceQuantity12Builder getOrCreatePq() {
			PriceQuantity12.PriceQuantity12Builder result;
			if (pq!=null) {
				result = pq;
			}
			else {
				result = pq = PriceQuantity12.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("rpq")
		public ResolvableAsset12.ResolvableAsset12Builder getRpq() {
			return rpq;
		}
		
		@Override
		public ResolvableAsset12.ResolvableAsset12Builder getOrCreateRpq() {
			ResolvableAsset12.ResolvableAsset12Builder result;
			if (rpq!=null) {
				result = rpq;
			}
			else {
				result = rpq = ResolvableAsset12.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("pq")
		public Top12.Top12Builder setPq(PriceQuantity12 pq) {
			this.pq = pq==null?null:pq.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("rpq")
		public Top12.Top12Builder setRpq(ResolvableAsset12 rpq) {
			this.rpq = rpq==null?null:rpq.toBuilder();
			return this;
		}
		
		@Override
		public Top12 build() {
			return new Top12.Top12Impl(this);
		}
		
		@Override
		public Top12.Top12Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top12.Top12Builder 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 Top12.Top12Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Top12.Top12Builder o = (Top12.Top12Builder) 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;
		
			Top12 _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 "Top12Builder {" +
				"pq=" + this.pq + ", " +
				"rpq=" + this.rpq +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy