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

com.rosetta.jptcaccessconditions.model.SomeConditionWrapper Maven / Gradle / Ivy

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

import com.google.common.collect.ImmutableList;
import com.rosetta.jptcaccessconditions.model.SomeCondition;
import com.rosetta.jptcaccessconditions.model.SomeConditionWrapper;
import com.rosetta.jptcaccessconditions.model.SomeConditionWrapper.SomeConditionWrapperBuilder;
import com.rosetta.jptcaccessconditions.model.SomeConditionWrapper.SomeConditionWrapperBuilderImpl;
import com.rosetta.jptcaccessconditions.model.SomeConditionWrapper.SomeConditionWrapperImpl;
import com.rosetta.jptcaccessconditions.model.meta.SomeConditionWrapperMeta;
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="SomeConditionWrapper", builder=SomeConditionWrapper.SomeConditionWrapperBuilderImpl.class, version="test")
public interface SomeConditionWrapper extends RosettaModelObject {

	SomeConditionWrapperMeta metaData = new SomeConditionWrapperMeta();

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

	/*********************** Build Methods  ***********************/
	SomeConditionWrapper build();
	
	SomeConditionWrapper.SomeConditionWrapperBuilder toBuilder();
	
	static SomeConditionWrapper.SomeConditionWrapperBuilder builder() {
		return new SomeConditionWrapper.SomeConditionWrapperBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return SomeConditionWrapper.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("concreteCondition"), processor, SomeCondition.class, getConcreteCondition());
	}
	

	/*********************** Builder Interface  ***********************/
	interface SomeConditionWrapperBuilder extends SomeConditionWrapper, RosettaModelObjectBuilder {
		SomeCondition.SomeConditionBuilder getOrCreateConcreteCondition(int _index);
		List getConcreteCondition();
		SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(SomeCondition concreteCondition0);
		SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(SomeCondition concreteCondition1, int _idx);
		SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(List concreteCondition2);
		SomeConditionWrapper.SomeConditionWrapperBuilder setConcreteCondition(List concreteCondition3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("concreteCondition"), processor, SomeCondition.SomeConditionBuilder.class, getConcreteCondition());
		}
		

		SomeConditionWrapper.SomeConditionWrapperBuilder prune();
	}

	/*********************** Immutable Implementation of SomeConditionWrapper  ***********************/
	class SomeConditionWrapperImpl implements SomeConditionWrapper {
		private final List concreteCondition;
		
		protected SomeConditionWrapperImpl(SomeConditionWrapper.SomeConditionWrapperBuilder builder) {
			this.concreteCondition = ofNullable(builder.getConcreteCondition()).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("concreteCondition")
		public List getConcreteCondition() {
			return concreteCondition;
		}
		
		@Override
		public SomeConditionWrapper build() {
			return this;
		}
		
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder toBuilder() {
			SomeConditionWrapper.SomeConditionWrapperBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(SomeConditionWrapper.SomeConditionWrapperBuilder builder) {
			ofNullable(getConcreteCondition()).ifPresent(builder::setConcreteCondition);
		}

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

	/*********************** Builder Implementation of SomeConditionWrapper  ***********************/
	class SomeConditionWrapperBuilderImpl implements SomeConditionWrapper.SomeConditionWrapperBuilder {
	
		protected List concreteCondition = new ArrayList<>();
	
		public SomeConditionWrapperBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("concreteCondition")
		public List getConcreteCondition() {
			return concreteCondition;
		}
		
		public SomeCondition.SomeConditionBuilder getOrCreateConcreteCondition(int _index) {
		
			if (concreteCondition==null) {
				this.concreteCondition = new ArrayList<>();
			}
			SomeCondition.SomeConditionBuilder result;
			return getIndex(concreteCondition, _index, () -> {
						SomeCondition.SomeConditionBuilder newConcreteCondition = SomeCondition.builder();
						return newConcreteCondition;
					});
		}
		
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(SomeCondition concreteCondition) {
			if (concreteCondition!=null) this.concreteCondition.add(concreteCondition.toBuilder());
			return this;
		}
		
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(SomeCondition concreteCondition, int _idx) {
			getIndex(this.concreteCondition, _idx, () -> concreteCondition.toBuilder());
			return this;
		}
		@Override 
		public SomeConditionWrapper.SomeConditionWrapperBuilder addConcreteCondition(List concreteConditions) {
			if (concreteConditions != null) {
				for (SomeCondition toAdd : concreteConditions) {
					this.concreteCondition.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("concreteCondition")
		public SomeConditionWrapper.SomeConditionWrapperBuilder setConcreteCondition(List concreteConditions) {
			if (concreteConditions == null)  {
				this.concreteCondition = new ArrayList<>();
			}
			else {
				this.concreteCondition = concreteConditions.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public SomeConditionWrapper build() {
			return new SomeConditionWrapper.SomeConditionWrapperImpl(this);
		}
		
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder prune() {
			concreteCondition = concreteCondition.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getConcreteCondition()!=null && getConcreteCondition().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public SomeConditionWrapper.SomeConditionWrapperBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			SomeConditionWrapper.SomeConditionWrapperBuilder o = (SomeConditionWrapper.SomeConditionWrapperBuilder) other;
			
			merger.mergeRosetta(getConcreteCondition(), o.getConcreteCondition(), this::getOrCreateConcreteCondition);
			
			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;
		
			SomeConditionWrapper _that = getType().cast(o);
		
			if (!ListEquals.listEquals(concreteCondition, _that.getConcreteCondition())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (concreteCondition != null ? concreteCondition.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "SomeConditionWrapperBuilder {" +
				"concreteCondition=" + this.concreteCondition +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy