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

com.rosetta.externalsynonym.model.Contract7 Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
import com.rosetta.externalsynonym.model.Contract7;
import com.rosetta.externalsynonym.model.Contract7.Contract7Builder;
import com.rosetta.externalsynonym.model.Contract7.Contract7BuilderImpl;
import com.rosetta.externalsynonym.model.Contract7.Contract7Impl;
import com.rosetta.externalsynonym.model.Identifier7;
import com.rosetta.externalsynonym.model.meta.Contract7Meta;
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="Contract7", builder=Contract7.Contract7BuilderImpl.class, version="test")
public interface Contract7 extends RosettaModelObject {

	Contract7Meta metaData = new Contract7Meta();

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

	/*********************** Build Methods  ***********************/
	Contract7 build();
	
	Contract7.Contract7Builder toBuilder();
	
	static Contract7.Contract7Builder builder() {
		return new Contract7.Contract7BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Contract7.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("id"), processor, Identifier7.class, getId());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Contract7Builder extends Contract7, RosettaModelObjectBuilder {
		Identifier7.Identifier7Builder getOrCreateId(int _index);
		List getId();
		Contract7.Contract7Builder addId(Identifier7 id0);
		Contract7.Contract7Builder addId(Identifier7 id1, int _idx);
		Contract7.Contract7Builder addId(List id2);
		Contract7.Contract7Builder setId(List id3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("id"), processor, Identifier7.Identifier7Builder.class, getId());
		}
		

		Contract7.Contract7Builder prune();
	}

	/*********************** Immutable Implementation of Contract7  ***********************/
	class Contract7Impl implements Contract7 {
		private final List id;
		
		protected Contract7Impl(Contract7.Contract7Builder builder) {
			this.id = ofNullable(builder.getId()).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("id")
		public List getId() {
			return id;
		}
		
		@Override
		public Contract7 build() {
			return this;
		}
		
		@Override
		public Contract7.Contract7Builder toBuilder() {
			Contract7.Contract7Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Contract7.Contract7Builder builder) {
			ofNullable(getId()).ifPresent(builder::setId);
		}

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

	/*********************** Builder Implementation of Contract7  ***********************/
	class Contract7BuilderImpl implements Contract7.Contract7Builder {
	
		protected List id = new ArrayList<>();
	
		public Contract7BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("id")
		public List getId() {
			return id;
		}
		
		public Identifier7.Identifier7Builder getOrCreateId(int _index) {
		
			if (id==null) {
				this.id = new ArrayList<>();
			}
			Identifier7.Identifier7Builder result;
			return getIndex(id, _index, () -> {
						Identifier7.Identifier7Builder newId = Identifier7.builder();
						return newId;
					});
		}
		
		@Override
		public Contract7.Contract7Builder addId(Identifier7 id) {
			if (id!=null) this.id.add(id.toBuilder());
			return this;
		}
		
		@Override
		public Contract7.Contract7Builder addId(Identifier7 id, int _idx) {
			getIndex(this.id, _idx, () -> id.toBuilder());
			return this;
		}
		@Override 
		public Contract7.Contract7Builder addId(List ids) {
			if (ids != null) {
				for (Identifier7 toAdd : ids) {
					this.id.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("id")
		public Contract7.Contract7Builder setId(List ids) {
			if (ids == null)  {
				this.id = new ArrayList<>();
			}
			else {
				this.id = ids.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public Contract7 build() {
			return new Contract7.Contract7Impl(this);
		}
		
		@Override
		public Contract7.Contract7Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Contract7.Contract7Builder prune() {
			id = id.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getId()!=null && getId().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Contract7.Contract7Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Contract7.Contract7Builder o = (Contract7.Contract7Builder) other;
			
			merger.mergeRosetta(getId(), o.getId(), this::getOrCreateId);
			
			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;
		
			Contract7 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(id, _that.getId())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (id != null ? id.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Contract7Builder {" +
				"id=" + this.id +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy