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

com.rosetta.testhard.model.Event_1 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.Event_1;
import com.rosetta.testhard.model.Event_1.Event_1Builder;
import com.rosetta.testhard.model.Event_1.Event_1BuilderImpl;
import com.rosetta.testhard.model.Event_1.Event_1Impl;
import com.rosetta.testhard.model.Identifier;
import com.rosetta.testhard.model.meta.Event_1Meta;
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="Event_1", builder=Event_1.Event_1BuilderImpl.class, version="test")
public interface Event_1 extends RosettaModelObject {

	Event_1Meta metaData = new Event_1Meta();

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

	/*********************** Build Methods  ***********************/
	Event_1 build();
	
	Event_1.Event_1Builder toBuilder();
	
	static Event_1.Event_1Builder builder() {
		return new Event_1.Event_1BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Event_1.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("ids"), processor, Identifier.class, getIds());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Event_1Builder extends Event_1, RosettaModelObjectBuilder {
		Identifier.IdentifierBuilder getOrCreateIds(int _index);
		List getIds();
		Event_1.Event_1Builder addIds(Identifier ids0);
		Event_1.Event_1Builder addIds(Identifier ids1, int _idx);
		Event_1.Event_1Builder addIds(List ids2);
		Event_1.Event_1Builder setIds(List ids3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("ids"), processor, Identifier.IdentifierBuilder.class, getIds());
		}
		

		Event_1.Event_1Builder prune();
	}

	/*********************** Immutable Implementation of Event_1  ***********************/
	class Event_1Impl implements Event_1 {
		private final List ids;
		
		protected Event_1Impl(Event_1.Event_1Builder builder) {
			this.ids = ofNullable(builder.getIds()).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("ids")
		public List getIds() {
			return ids;
		}
		
		@Override
		public Event_1 build() {
			return this;
		}
		
		@Override
		public Event_1.Event_1Builder toBuilder() {
			Event_1.Event_1Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Event_1.Event_1Builder builder) {
			ofNullable(getIds()).ifPresent(builder::setIds);
		}

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

	/*********************** Builder Implementation of Event_1  ***********************/
	class Event_1BuilderImpl implements Event_1.Event_1Builder {
	
		protected List ids = new ArrayList<>();
	
		public Event_1BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("ids")
		public List getIds() {
			return ids;
		}
		
		public Identifier.IdentifierBuilder getOrCreateIds(int _index) {
		
			if (ids==null) {
				this.ids = new ArrayList<>();
			}
			Identifier.IdentifierBuilder result;
			return getIndex(ids, _index, () -> {
						Identifier.IdentifierBuilder newIds = Identifier.builder();
						return newIds;
					});
		}
		
		@Override
		public Event_1.Event_1Builder addIds(Identifier ids) {
			if (ids!=null) this.ids.add(ids.toBuilder());
			return this;
		}
		
		@Override
		public Event_1.Event_1Builder addIds(Identifier ids, int _idx) {
			getIndex(this.ids, _idx, () -> ids.toBuilder());
			return this;
		}
		@Override 
		public Event_1.Event_1Builder addIds(List idss) {
			if (idss != null) {
				for (Identifier toAdd : idss) {
					this.ids.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("ids")
		public Event_1.Event_1Builder setIds(List idss) {
			if (idss == null)  {
				this.ids = new ArrayList<>();
			}
			else {
				this.ids = idss.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public Event_1 build() {
			return new Event_1.Event_1Impl(this);
		}
		
		@Override
		public Event_1.Event_1Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Event_1.Event_1Builder prune() {
			ids = ids.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getIds()!=null && getIds().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Event_1.Event_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Event_1.Event_1Builder o = (Event_1.Event_1Builder) other;
			
			merger.mergeRosetta(getIds(), o.getIds(), this::getOrCreateIds);
			
			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;
		
			Event_1 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(ids, _that.getIds())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (ids != null ? ids.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Event_1Builder {" +
				"ids=" + this.ids +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy