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

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

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

import com.rosetta.metatest.model.PriceQuantity13;
import com.rosetta.metatest.model.ResolvableAsset13;
import com.rosetta.metatest.model.Top13;
import com.rosetta.metatest.model.Top13.Top13Builder;
import com.rosetta.metatest.model.Top13.Top13BuilderImpl;
import com.rosetta.metatest.model.Top13.Top13Impl;
import com.rosetta.metatest.model.meta.Top13Meta;
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="Top13", builder=Top13.Top13BuilderImpl.class, version="test")
public interface Top13 extends RosettaModelObject {

	Top13Meta metaData = new Top13Meta();

	/*********************** Getter Methods  ***********************/
	PriceQuantity13 getPq();
	ResolvableAsset13 getRpq();

	/*********************** Build Methods  ***********************/
	Top13 build();
	
	Top13.Top13Builder toBuilder();
	
	static Top13.Top13Builder builder() {
		return new Top13.Top13BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface Top13Builder extends Top13, RosettaModelObjectBuilder {
		PriceQuantity13.PriceQuantity13Builder getOrCreatePq();
		PriceQuantity13.PriceQuantity13Builder getPq();
		ResolvableAsset13.ResolvableAsset13Builder getOrCreateRpq();
		ResolvableAsset13.ResolvableAsset13Builder getRpq();
		Top13.Top13Builder setPq(PriceQuantity13 pq);
		Top13.Top13Builder setRpq(ResolvableAsset13 rpq);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("pq"), processor, PriceQuantity13.PriceQuantity13Builder.class, getPq());
			processRosetta(path.newSubPath("rpq"), processor, ResolvableAsset13.ResolvableAsset13Builder.class, getRpq());
		}
		

		Top13.Top13Builder prune();
	}

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

	/*********************** Builder Implementation of Top13  ***********************/
	class Top13BuilderImpl implements Top13.Top13Builder {
	
		protected PriceQuantity13.PriceQuantity13Builder pq;
		protected ResolvableAsset13.ResolvableAsset13Builder rpq;
	
		public Top13BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("pq")
		public PriceQuantity13.PriceQuantity13Builder getPq() {
			return pq;
		}
		
		@Override
		public PriceQuantity13.PriceQuantity13Builder getOrCreatePq() {
			PriceQuantity13.PriceQuantity13Builder result;
			if (pq!=null) {
				result = pq;
			}
			else {
				result = pq = PriceQuantity13.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("rpq")
		public ResolvableAsset13.ResolvableAsset13Builder getRpq() {
			return rpq;
		}
		
		@Override
		public ResolvableAsset13.ResolvableAsset13Builder getOrCreateRpq() {
			ResolvableAsset13.ResolvableAsset13Builder result;
			if (rpq!=null) {
				result = rpq;
			}
			else {
				result = rpq = ResolvableAsset13.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("pq")
		public Top13.Top13Builder setPq(PriceQuantity13 pq) {
			this.pq = pq==null?null:pq.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("rpq")
		public Top13.Top13Builder setRpq(ResolvableAsset13 rpq) {
			this.rpq = rpq==null?null:rpq.toBuilder();
			return this;
		}
		
		@Override
		public Top13 build() {
			return new Top13.Top13Impl(this);
		}
		
		@Override
		public Top13.Top13Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top13.Top13Builder 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 Top13.Top13Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Top13.Top13Builder o = (Top13.Top13Builder) 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;
		
			Top13 _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 "Top13Builder {" +
				"pq=" + this.pq + ", " +
				"rpq=" + this.rpq +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy