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

com.rosetta.testconditional.model.V21_1 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.V21_1;
import com.rosetta.testconditional.model.V21_1.V21_1Builder;
import com.rosetta.testconditional.model.V21_1.V21_1BuilderImpl;
import com.rosetta.testconditional.model.V21_1.V21_1Impl;
import com.rosetta.testconditional.model.W21_1;
import com.rosetta.testconditional.model.meta.V21_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="V21_1", builder=V21_1.V21_1BuilderImpl.class, version="test")
public interface V21_1 extends RosettaModelObject {

	V21_1Meta metaData = new V21_1Meta();

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

	/*********************** Build Methods  ***********************/
	V21_1 build();
	
	V21_1.V21_1Builder toBuilder();
	
	static V21_1.V21_1Builder builder() {
		return new V21_1.V21_1BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return V21_1.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("wField"), processor, W21_1.class, getWField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface V21_1Builder extends V21_1, RosettaModelObjectBuilder {
		W21_1.W21_1Builder getOrCreateWField(int _index);
		List getWField();
		V21_1.V21_1Builder addWField(W21_1 wField0);
		V21_1.V21_1Builder addWField(W21_1 wField1, int _idx);
		V21_1.V21_1Builder addWField(List wField2);
		V21_1.V21_1Builder setWField(List wField3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("wField"), processor, W21_1.W21_1Builder.class, getWField());
		}
		

		V21_1.V21_1Builder prune();
	}

	/*********************** Immutable Implementation of V21_1  ***********************/
	class V21_1Impl implements V21_1 {
		private final List wField;
		
		protected V21_1Impl(V21_1.V21_1Builder builder) {
			this.wField = ofNullable(builder.getWField()).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("wField")
		public List getWField() {
			return wField;
		}
		
		@Override
		public V21_1 build() {
			return this;
		}
		
		@Override
		public V21_1.V21_1Builder toBuilder() {
			V21_1.V21_1Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(V21_1.V21_1Builder builder) {
			ofNullable(getWField()).ifPresent(builder::setWField);
		}

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

	/*********************** Builder Implementation of V21_1  ***********************/
	class V21_1BuilderImpl implements V21_1.V21_1Builder {
	
		protected List wField = new ArrayList<>();
	
		public V21_1BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("wField")
		public List getWField() {
			return wField;
		}
		
		public W21_1.W21_1Builder getOrCreateWField(int _index) {
		
			if (wField==null) {
				this.wField = new ArrayList<>();
			}
			W21_1.W21_1Builder result;
			return getIndex(wField, _index, () -> {
						W21_1.W21_1Builder newWField = W21_1.builder();
						return newWField;
					});
		}
		
		@Override
		public V21_1.V21_1Builder addWField(W21_1 wField) {
			if (wField!=null) this.wField.add(wField.toBuilder());
			return this;
		}
		
		@Override
		public V21_1.V21_1Builder addWField(W21_1 wField, int _idx) {
			getIndex(this.wField, _idx, () -> wField.toBuilder());
			return this;
		}
		@Override 
		public V21_1.V21_1Builder addWField(List wFields) {
			if (wFields != null) {
				for (W21_1 toAdd : wFields) {
					this.wField.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("wField")
		public V21_1.V21_1Builder setWField(List wFields) {
			if (wFields == null)  {
				this.wField = new ArrayList<>();
			}
			else {
				this.wField = wFields.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public V21_1 build() {
			return new V21_1.V21_1Impl(this);
		}
		
		@Override
		public V21_1.V21_1Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public V21_1.V21_1Builder prune() {
			wField = wField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getWField()!=null && getWField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public V21_1.V21_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			V21_1.V21_1Builder o = (V21_1.V21_1Builder) other;
			
			merger.mergeRosetta(getWField(), o.getWField(), this::getOrCreateWField);
			
			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;
		
			V21_1 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(wField, _that.getWField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (wField != null ? wField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "V21_1Builder {" +
				"wField=" + this.wField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy