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

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

The 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.EcTerms;
import com.rosetta.testother.model.EcTerms.EcTermsBuilder;
import com.rosetta.testother.model.EcTerms.EcTermsBuilderImpl;
import com.rosetta.testother.model.EcTerms.EcTermsImpl;
import com.rosetta.testother.model.Payout;
import com.rosetta.testother.model.Payout.PayoutBuilder;
import com.rosetta.testother.model.meta.EcTermsMeta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	EcTermsMeta metaData = new EcTermsMeta();

	/*********************** Getter Methods  ***********************/
	Payout getPayout();

	/*********************** Build Methods  ***********************/
	EcTerms build();
	
	EcTerms.EcTermsBuilder toBuilder();
	
	static EcTerms.EcTermsBuilder builder() {
		return new EcTerms.EcTermsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return EcTerms.class;
	}
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("payout"), processor, Payout.class, getPayout());
	}
	

	/*********************** Builder Interface  ***********************/
	interface EcTermsBuilder extends EcTerms, RosettaModelObjectBuilder {
		Payout.PayoutBuilder getOrCreatePayout();
		@Override
		Payout.PayoutBuilder getPayout();
		EcTerms.EcTermsBuilder setPayout(Payout payout);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("payout"), processor, Payout.PayoutBuilder.class, getPayout());
		}
		

		EcTerms.EcTermsBuilder prune();
	}

	/*********************** Immutable Implementation of EcTerms  ***********************/
	class EcTermsImpl implements EcTerms {
		private final Payout payout;
		
		protected EcTermsImpl(EcTerms.EcTermsBuilder builder) {
			this.payout = ofNullable(builder.getPayout()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("payout")
		public Payout getPayout() {
			return payout;
		}
		
		@Override
		public EcTerms build() {
			return this;
		}
		
		@Override
		public EcTerms.EcTermsBuilder toBuilder() {
			EcTerms.EcTermsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(EcTerms.EcTermsBuilder builder) {
			ofNullable(getPayout()).ifPresent(builder::setPayout);
		}

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

	/*********************** Builder Implementation of EcTerms  ***********************/
	class EcTermsBuilderImpl implements EcTerms.EcTermsBuilder {
	
		protected Payout.PayoutBuilder payout;
		
		@Override
		@RosettaAttribute("payout")
		public Payout.PayoutBuilder getPayout() {
			return payout;
		}
		
		@Override
		public Payout.PayoutBuilder getOrCreatePayout() {
			Payout.PayoutBuilder result;
			if (payout!=null) {
				result = payout;
			}
			else {
				result = payout = Payout.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("payout")
		public EcTerms.EcTermsBuilder setPayout(Payout _payout) {
			this.payout = _payout == null ? null : _payout.toBuilder();
			return this;
		}
		
		@Override
		public EcTerms build() {
			return new EcTerms.EcTermsImpl(this);
		}
		
		@Override
		public EcTerms.EcTermsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public EcTerms.EcTermsBuilder prune() {
			if (payout!=null && !payout.prune().hasData()) payout = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPayout()!=null && getPayout().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public EcTerms.EcTermsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			EcTerms.EcTermsBuilder o = (EcTerms.EcTermsBuilder) other;
			
			merger.mergeRosetta(getPayout(), o.getPayout(), this::setPayout);
			
			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;
		
			EcTerms _that = getType().cast(o);
		
			if (!Objects.equals(payout, _that.getPayout())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (payout != null ? payout.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "EcTermsBuilder {" +
				"payout=" + this.payout +
			'}';
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy