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

com.rosetta.testcard.model.W10_2 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testcard.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.testcard.model.W10_2;
import com.rosetta.testcard.model.W10_2.W10_2Builder;
import com.rosetta.testcard.model.W10_2.W10_2BuilderImpl;
import com.rosetta.testcard.model.W10_2.W10_2Impl;
import com.rosetta.testcard.model.X10_2;
import com.rosetta.testcard.model.meta.W10_2Meta;
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="W10_2", builder=W10_2.W10_2BuilderImpl.class, version="test")
public interface W10_2 extends RosettaModelObject {

	W10_2Meta metaData = new W10_2Meta();

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

	/*********************** Build Methods  ***********************/
	W10_2 build();
	
	W10_2.W10_2Builder toBuilder();
	
	static W10_2.W10_2Builder builder() {
		return new W10_2.W10_2BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return W10_2.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("xField"), processor, X10_2.class, getXField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface W10_2Builder extends W10_2, RosettaModelObjectBuilder {
		X10_2.X10_2Builder getOrCreateXField(int _index);
		List getXField();
		W10_2.W10_2Builder addXField(X10_2 xField0);
		W10_2.W10_2Builder addXField(X10_2 xField1, int _idx);
		W10_2.W10_2Builder addXField(List xField2);
		W10_2.W10_2Builder setXField(List xField3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("xField"), processor, X10_2.X10_2Builder.class, getXField());
		}
		

		W10_2.W10_2Builder prune();
	}

	/*********************** Immutable Implementation of W10_2  ***********************/
	class W10_2Impl implements W10_2 {
		private final List xField;
		
		protected W10_2Impl(W10_2.W10_2Builder builder) {
			this.xField = ofNullable(builder.getXField()).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("xField")
		public List getXField() {
			return xField;
		}
		
		@Override
		public W10_2 build() {
			return this;
		}
		
		@Override
		public W10_2.W10_2Builder toBuilder() {
			W10_2.W10_2Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(W10_2.W10_2Builder builder) {
			ofNullable(getXField()).ifPresent(builder::setXField);
		}

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

	/*********************** Builder Implementation of W10_2  ***********************/
	class W10_2BuilderImpl implements W10_2.W10_2Builder {
	
		protected List xField = new ArrayList<>();
	
		public W10_2BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("xField")
		public List getXField() {
			return xField;
		}
		
		public X10_2.X10_2Builder getOrCreateXField(int _index) {
		
			if (xField==null) {
				this.xField = new ArrayList<>();
			}
			X10_2.X10_2Builder result;
			return getIndex(xField, _index, () -> {
						X10_2.X10_2Builder newXField = X10_2.builder();
						return newXField;
					});
		}
		
		@Override
		public W10_2.W10_2Builder addXField(X10_2 xField) {
			if (xField!=null) this.xField.add(xField.toBuilder());
			return this;
		}
		
		@Override
		public W10_2.W10_2Builder addXField(X10_2 xField, int _idx) {
			getIndex(this.xField, _idx, () -> xField.toBuilder());
			return this;
		}
		@Override 
		public W10_2.W10_2Builder addXField(List xFields) {
			if (xFields != null) {
				for (X10_2 toAdd : xFields) {
					this.xField.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("xField")
		public W10_2.W10_2Builder setXField(List xFields) {
			if (xFields == null)  {
				this.xField = new ArrayList<>();
			}
			else {
				this.xField = xFields.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public W10_2 build() {
			return new W10_2.W10_2Impl(this);
		}
		
		@Override
		public W10_2.W10_2Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W10_2.W10_2Builder prune() {
			xField = xField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getXField()!=null && getXField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W10_2.W10_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			W10_2.W10_2Builder o = (W10_2.W10_2Builder) other;
			
			merger.mergeRosetta(getXField(), o.getXField(), this::getOrCreateXField);
			
			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;
		
			W10_2 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(xField, _that.getXField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "W10_2Builder {" +
				"xField=" + this.xField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy