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

com.rosetta.testhard.model.Payout1 Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
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.testhard.model.InterestRatePayout;
import com.rosetta.testhard.model.Payout1;
import com.rosetta.testhard.model.Payout1.Payout1Builder;
import com.rosetta.testhard.model.Payout1.Payout1BuilderImpl;
import com.rosetta.testhard.model.Payout1.Payout1Impl;
import com.rosetta.testhard.model.meta.Payout1Meta;
import com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import static java.util.Optional.ofNullable;

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

	Payout1Meta metaData = new Payout1Meta();

	/*********************** Getter Methods  ***********************/
	List getIrps();

	/*********************** Build Methods  ***********************/
	Payout1 build();
	
	Payout1.Payout1Builder toBuilder();
	
	static Payout1.Payout1Builder builder() {
		return new Payout1.Payout1BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Payout1.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("irps"), processor, InterestRatePayout.class, getIrps());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Payout1Builder extends Payout1, RosettaModelObjectBuilder {
		InterestRatePayout.InterestRatePayoutBuilder getOrCreateIrps(int _index);
		List getIrps();
		Payout1.Payout1Builder addIrps(InterestRatePayout irps0);
		Payout1.Payout1Builder addIrps(InterestRatePayout irps1, int _idx);
		Payout1.Payout1Builder addIrps(List irps2);
		Payout1.Payout1Builder setIrps(List irps3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("irps"), processor, InterestRatePayout.InterestRatePayoutBuilder.class, getIrps());
		}
		

		Payout1.Payout1Builder prune();
	}

	/*********************** Immutable Implementation of Payout1  ***********************/
	class Payout1Impl implements Payout1 {
		private final List irps;
		
		protected Payout1Impl(Payout1.Payout1Builder builder) {
			this.irps = ofNullable(builder.getIrps()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
		}
		
		@Override
		@RosettaAttribute("irps")
		public List getIrps() {
			return irps;
		}
		
		@Override
		public Payout1 build() {
			return this;
		}
		
		@Override
		public Payout1.Payout1Builder toBuilder() {
			Payout1.Payout1Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Payout1.Payout1Builder builder) {
			ofNullable(getIrps()).ifPresent(builder::setIrps);
		}

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

	/*********************** Builder Implementation of Payout1  ***********************/
	class Payout1BuilderImpl implements Payout1.Payout1Builder {
	
		protected List irps = new ArrayList<>();
	
		public Payout1BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("irps")
		public List getIrps() {
			return irps;
		}
		
		public InterestRatePayout.InterestRatePayoutBuilder getOrCreateIrps(int _index) {
		
			if (irps==null) {
				this.irps = new ArrayList<>();
			}
			InterestRatePayout.InterestRatePayoutBuilder result;
			return getIndex(irps, _index, () -> {
						InterestRatePayout.InterestRatePayoutBuilder newIrps = InterestRatePayout.builder();
						return newIrps;
					});
		}
		
		@Override
		public Payout1.Payout1Builder addIrps(InterestRatePayout irps) {
			if (irps!=null) this.irps.add(irps.toBuilder());
			return this;
		}
		
		@Override
		public Payout1.Payout1Builder addIrps(InterestRatePayout irps, int _idx) {
			getIndex(this.irps, _idx, () -> irps.toBuilder());
			return this;
		}
		@Override 
		public Payout1.Payout1Builder addIrps(List irpss) {
			if (irpss != null) {
				for (InterestRatePayout toAdd : irpss) {
					this.irps.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("irps")
		public Payout1.Payout1Builder setIrps(List irpss) {
			if (irpss == null)  {
				this.irps = new ArrayList<>();
			}
			else {
				this.irps = irpss.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public Payout1 build() {
			return new Payout1.Payout1Impl(this);
		}
		
		@Override
		public Payout1.Payout1Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Payout1.Payout1Builder prune() {
			irps = irps.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getIrps()!=null && getIrps().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Payout1.Payout1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Payout1.Payout1Builder o = (Payout1.Payout1Builder) other;
			
			merger.mergeRosetta(getIrps(), o.getIrps(), this::getOrCreateIrps);
			
			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;
		
			Payout1 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(irps, _that.getIrps())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (irps != null ? irps.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Payout1Builder {" +
				"irps=" + this.irps +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy