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

com.rosetta.jptlegalagreement.model.ChargorPostingObligations Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.ChargorPostingObligations;
import com.rosetta.jptlegalagreement.model.ChargorPostingObligations.ChargorPostingObligationsBuilder;
import com.rosetta.jptlegalagreement.model.ChargorPostingObligations.ChargorPostingObligationsBuilderImpl;
import com.rosetta.jptlegalagreement.model.ChargorPostingObligations.ChargorPostingObligationsImpl;
import com.rosetta.jptlegalagreement.model.PostingObligationsElection;
import com.rosetta.jptlegalagreement.model.meta.ChargorPostingObligationsMeta;
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.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="ChargorPostingObligations", builder=ChargorPostingObligations.ChargorPostingObligationsBuilderImpl.class, version="test")
public interface ChargorPostingObligations extends RosettaModelObject {

	ChargorPostingObligationsMeta metaData = new ChargorPostingObligationsMeta();

	/*********************** Getter Methods  ***********************/
	String getName();
	List getPartyElection();

	/*********************** Build Methods  ***********************/
	ChargorPostingObligations build();
	
	ChargorPostingObligations.ChargorPostingObligationsBuilder toBuilder();
	
	static ChargorPostingObligations.ChargorPostingObligationsBuilder builder() {
		return new ChargorPostingObligations.ChargorPostingObligationsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return ChargorPostingObligations.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("name"), String.class, getName(), this);
		processRosetta(path.newSubPath("partyElection"), processor, PostingObligationsElection.class, getPartyElection());
	}
	

	/*********************** Builder Interface  ***********************/
	interface ChargorPostingObligationsBuilder extends ChargorPostingObligations, RosettaModelObjectBuilder {
		PostingObligationsElection.PostingObligationsElectionBuilder getOrCreatePartyElection(int _index);
		List getPartyElection();
		ChargorPostingObligations.ChargorPostingObligationsBuilder setName(String name);
		ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(PostingObligationsElection partyElection0);
		ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(PostingObligationsElection partyElection1, int _idx);
		ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(List partyElection2);
		ChargorPostingObligations.ChargorPostingObligationsBuilder setPartyElection(List partyElection3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("name"), String.class, getName(), this);
			processRosetta(path.newSubPath("partyElection"), processor, PostingObligationsElection.PostingObligationsElectionBuilder.class, getPartyElection());
		}
		

		ChargorPostingObligations.ChargorPostingObligationsBuilder prune();
	}

	/*********************** Immutable Implementation of ChargorPostingObligations  ***********************/
	class ChargorPostingObligationsImpl implements ChargorPostingObligations {
		private final String name;
		private final List partyElection;
		
		protected ChargorPostingObligationsImpl(ChargorPostingObligations.ChargorPostingObligationsBuilder builder) {
			this.name = builder.getName();
			this.partyElection = ofNullable(builder.getPartyElection()).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("name")
		public String getName() {
			return name;
		}
		
		@Override
		@RosettaAttribute("partyElection")
		public List getPartyElection() {
			return partyElection;
		}
		
		@Override
		public ChargorPostingObligations build() {
			return this;
		}
		
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder toBuilder() {
			ChargorPostingObligations.ChargorPostingObligationsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(ChargorPostingObligations.ChargorPostingObligationsBuilder builder) {
			ofNullable(getName()).ifPresent(builder::setName);
			ofNullable(getPartyElection()).ifPresent(builder::setPartyElection);
		}

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

	/*********************** Builder Implementation of ChargorPostingObligations  ***********************/
	class ChargorPostingObligationsBuilderImpl implements ChargorPostingObligations.ChargorPostingObligationsBuilder {
	
		protected String name;
		protected List partyElection = new ArrayList<>();
	
		public ChargorPostingObligationsBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("name")
		public String getName() {
			return name;
		}
		
		@Override
		@RosettaAttribute("partyElection")
		public List getPartyElection() {
			return partyElection;
		}
		
		public PostingObligationsElection.PostingObligationsElectionBuilder getOrCreatePartyElection(int _index) {
		
			if (partyElection==null) {
				this.partyElection = new ArrayList<>();
			}
			PostingObligationsElection.PostingObligationsElectionBuilder result;
			return getIndex(partyElection, _index, () -> {
						PostingObligationsElection.PostingObligationsElectionBuilder newPartyElection = PostingObligationsElection.builder();
						return newPartyElection;
					});
		}
		
		@Override
		@RosettaAttribute("name")
		public ChargorPostingObligations.ChargorPostingObligationsBuilder setName(String name) {
			this.name = name==null?null:name;
			return this;
		}
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(PostingObligationsElection partyElection) {
			if (partyElection!=null) this.partyElection.add(partyElection.toBuilder());
			return this;
		}
		
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(PostingObligationsElection partyElection, int _idx) {
			getIndex(this.partyElection, _idx, () -> partyElection.toBuilder());
			return this;
		}
		@Override 
		public ChargorPostingObligations.ChargorPostingObligationsBuilder addPartyElection(List partyElections) {
			if (partyElections != null) {
				for (PostingObligationsElection toAdd : partyElections) {
					this.partyElection.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("partyElection")
		public ChargorPostingObligations.ChargorPostingObligationsBuilder setPartyElection(List partyElections) {
			if (partyElections == null)  {
				this.partyElection = new ArrayList<>();
			}
			else {
				this.partyElection = partyElections.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public ChargorPostingObligations build() {
			return new ChargorPostingObligations.ChargorPostingObligationsImpl(this);
		}
		
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder prune() {
			partyElection = partyElection.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getName()!=null) return true;
			if (getPartyElection()!=null && getPartyElection().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public ChargorPostingObligations.ChargorPostingObligationsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			ChargorPostingObligations.ChargorPostingObligationsBuilder o = (ChargorPostingObligations.ChargorPostingObligationsBuilder) other;
			
			merger.mergeRosetta(getPartyElection(), o.getPartyElection(), this::getOrCreatePartyElection);
			
			merger.mergeBasic(getName(), o.getName(), this::setName);
			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;
		
			ChargorPostingObligations _that = getType().cast(o);
		
			if (!Objects.equals(name, _that.getName())) return false;
			if (!ListEquals.listEquals(partyElection, _that.getPartyElection())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (name != null ? name.hashCode() : 0);
			_result = 31 * _result + (partyElection != null ? partyElection.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "ChargorPostingObligationsBuilder {" +
				"name=" + this.name + ", " +
				"partyElection=" + this.partyElection +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy