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

com.rosetta.testconditional.model.U15 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testconditional.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.testconditional.model.U15;
import com.rosetta.testconditional.model.U15.U15Builder;
import com.rosetta.testconditional.model.U15.U15BuilderImpl;
import com.rosetta.testconditional.model.U15.U15Impl;
import com.rosetta.testconditional.model.V15;
import com.rosetta.testconditional.model.meta.U15Meta;
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="U15", builder=U15.U15BuilderImpl.class, version="test")
public interface U15 extends RosettaModelObject {

	U15Meta metaData = new U15Meta();

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

	/*********************** Build Methods  ***********************/
	U15 build();
	
	U15.U15Builder toBuilder();
	
	static U15.U15Builder builder() {
		return new U15.U15BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return U15.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("vField"), processor, V15.class, getVField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface U15Builder extends U15, RosettaModelObjectBuilder {
		V15.V15Builder getOrCreateVField(int _index);
		List getVField();
		U15.U15Builder addVField(V15 vField0);
		U15.U15Builder addVField(V15 vField1, int _idx);
		U15.U15Builder addVField(List vField2);
		U15.U15Builder setVField(List vField3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("vField"), processor, V15.V15Builder.class, getVField());
		}
		

		U15.U15Builder prune();
	}

	/*********************** Immutable Implementation of U15  ***********************/
	class U15Impl implements U15 {
		private final List vField;
		
		protected U15Impl(U15.U15Builder builder) {
			this.vField = ofNullable(builder.getVField()).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("vField")
		public List getVField() {
			return vField;
		}
		
		@Override
		public U15 build() {
			return this;
		}
		
		@Override
		public U15.U15Builder toBuilder() {
			U15.U15Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(U15.U15Builder builder) {
			ofNullable(getVField()).ifPresent(builder::setVField);
		}

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

	/*********************** Builder Implementation of U15  ***********************/
	class U15BuilderImpl implements U15.U15Builder {
	
		protected List vField = new ArrayList<>();
	
		public U15BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("vField")
		public List getVField() {
			return vField;
		}
		
		public V15.V15Builder getOrCreateVField(int _index) {
		
			if (vField==null) {
				this.vField = new ArrayList<>();
			}
			V15.V15Builder result;
			return getIndex(vField, _index, () -> {
						V15.V15Builder newVField = V15.builder();
						return newVField;
					});
		}
		
		@Override
		public U15.U15Builder addVField(V15 vField) {
			if (vField!=null) this.vField.add(vField.toBuilder());
			return this;
		}
		
		@Override
		public U15.U15Builder addVField(V15 vField, int _idx) {
			getIndex(this.vField, _idx, () -> vField.toBuilder());
			return this;
		}
		@Override 
		public U15.U15Builder addVField(List vFields) {
			if (vFields != null) {
				for (V15 toAdd : vFields) {
					this.vField.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("vField")
		public U15.U15Builder setVField(List vFields) {
			if (vFields == null)  {
				this.vField = new ArrayList<>();
			}
			else {
				this.vField = vFields.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public U15 build() {
			return new U15.U15Impl(this);
		}
		
		@Override
		public U15.U15Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public U15.U15Builder prune() {
			vField = vField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getVField()!=null && getVField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public U15.U15Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			U15.U15Builder o = (U15.U15Builder) other;
			
			merger.mergeRosetta(getVField(), o.getVField(), this::getOrCreateVField);
			
			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;
		
			U15 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(vField, _that.getVField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (vField != null ? vField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "U15Builder {" +
				"vField=" + this.vField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy