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

com.rosetta.jptcadditionalterminationevent.model.AccessConditions Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
import com.rosetta.jptcadditionalterminationevent.model.AccessConditions;
import com.rosetta.jptcadditionalterminationevent.model.AccessConditions.AccessConditionsBuilder;
import com.rosetta.jptcadditionalterminationevent.model.AccessConditions.AccessConditionsBuilderImpl;
import com.rosetta.jptcadditionalterminationevent.model.AccessConditions.AccessConditionsImpl;
import com.rosetta.jptcadditionalterminationevent.model.AdditionalTerminationEvent;
import com.rosetta.jptcadditionalterminationevent.model.meta.AccessConditionsMeta;
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="AccessConditions", builder=AccessConditions.AccessConditionsBuilderImpl.class, version="test")
public interface AccessConditions extends RosettaModelObject {

	AccessConditionsMeta metaData = new AccessConditionsMeta();

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

	/*********************** Build Methods  ***********************/
	AccessConditions build();
	
	AccessConditions.AccessConditionsBuilder toBuilder();
	
	static AccessConditions.AccessConditionsBuilder builder() {
		return new AccessConditions.AccessConditionsBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return AccessConditions.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("events"), processor, AdditionalTerminationEvent.class, getEvents());
	}
	

	/*********************** Builder Interface  ***********************/
	interface AccessConditionsBuilder extends AccessConditions, RosettaModelObjectBuilder {
		AdditionalTerminationEvent.AdditionalTerminationEventBuilder getOrCreateEvents(int _index);
		List getEvents();
		AccessConditions.AccessConditionsBuilder addEvents(AdditionalTerminationEvent events0);
		AccessConditions.AccessConditionsBuilder addEvents(AdditionalTerminationEvent events1, int _idx);
		AccessConditions.AccessConditionsBuilder addEvents(List events2);
		AccessConditions.AccessConditionsBuilder setEvents(List events3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("events"), processor, AdditionalTerminationEvent.AdditionalTerminationEventBuilder.class, getEvents());
		}
		

		AccessConditions.AccessConditionsBuilder prune();
	}

	/*********************** Immutable Implementation of AccessConditions  ***********************/
	class AccessConditionsImpl implements AccessConditions {
		private final List events;
		
		protected AccessConditionsImpl(AccessConditions.AccessConditionsBuilder builder) {
			this.events = ofNullable(builder.getEvents()).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("events")
		public List getEvents() {
			return events;
		}
		
		@Override
		public AccessConditions build() {
			return this;
		}
		
		@Override
		public AccessConditions.AccessConditionsBuilder toBuilder() {
			AccessConditions.AccessConditionsBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(AccessConditions.AccessConditionsBuilder builder) {
			ofNullable(getEvents()).ifPresent(builder::setEvents);
		}

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

	/*********************** Builder Implementation of AccessConditions  ***********************/
	class AccessConditionsBuilderImpl implements AccessConditions.AccessConditionsBuilder {
	
		protected List events = new ArrayList<>();
	
		public AccessConditionsBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("events")
		public List getEvents() {
			return events;
		}
		
		public AdditionalTerminationEvent.AdditionalTerminationEventBuilder getOrCreateEvents(int _index) {
		
			if (events==null) {
				this.events = new ArrayList<>();
			}
			AdditionalTerminationEvent.AdditionalTerminationEventBuilder result;
			return getIndex(events, _index, () -> {
						AdditionalTerminationEvent.AdditionalTerminationEventBuilder newEvents = AdditionalTerminationEvent.builder();
						return newEvents;
					});
		}
		
		@Override
		public AccessConditions.AccessConditionsBuilder addEvents(AdditionalTerminationEvent events) {
			if (events!=null) this.events.add(events.toBuilder());
			return this;
		}
		
		@Override
		public AccessConditions.AccessConditionsBuilder addEvents(AdditionalTerminationEvent events, int _idx) {
			getIndex(this.events, _idx, () -> events.toBuilder());
			return this;
		}
		@Override 
		public AccessConditions.AccessConditionsBuilder addEvents(List eventss) {
			if (eventss != null) {
				for (AdditionalTerminationEvent toAdd : eventss) {
					this.events.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("events")
		public AccessConditions.AccessConditionsBuilder setEvents(List eventss) {
			if (eventss == null)  {
				this.events = new ArrayList<>();
			}
			else {
				this.events = eventss.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public AccessConditions build() {
			return new AccessConditions.AccessConditionsImpl(this);
		}
		
		@Override
		public AccessConditions.AccessConditionsBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public AccessConditions.AccessConditionsBuilder prune() {
			events = events.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getEvents()!=null && getEvents().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public AccessConditions.AccessConditionsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			AccessConditions.AccessConditionsBuilder o = (AccessConditions.AccessConditionsBuilder) other;
			
			merger.mergeRosetta(getEvents(), o.getEvents(), this::getOrCreateEvents);
			
			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;
		
			AccessConditions _that = getType().cast(o);
		
			if (!ListEquals.listEquals(events, _that.getEvents())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (events != null ? events.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "AccessConditionsBuilder {" +
				"events=" + this.events +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy