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

com.rosetta.testother.model.Top8Super Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testother.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.testother.model.A8_1;
import com.rosetta.testother.model.Top8Super;
import com.rosetta.testother.model.Top8Super.Top8SuperBuilder;
import com.rosetta.testother.model.Top8Super.Top8SuperBuilderImpl;
import com.rosetta.testother.model.Top8Super.Top8SuperImpl;
import com.rosetta.testother.model.meta.Top8SuperMeta;
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="Top8Super", builder=Top8Super.Top8SuperBuilderImpl.class, version="test")
public interface Top8Super extends RosettaModelObject {

	Top8SuperMeta metaData = new Top8SuperMeta();

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

	/*********************** Build Methods  ***********************/
	Top8Super build();
	
	Top8Super.Top8SuperBuilder toBuilder();
	
	static Top8Super.Top8SuperBuilder builder() {
		return new Top8Super.Top8SuperBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Top8Super.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("a1Field"), processor, A8_1.class, getA1Field());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Top8SuperBuilder extends Top8Super, RosettaModelObjectBuilder {
		A8_1.A8_1Builder getOrCreateA1Field(int _index);
		List getA1Field();
		Top8Super.Top8SuperBuilder addA1Field(A8_1 a1Field0);
		Top8Super.Top8SuperBuilder addA1Field(A8_1 a1Field1, int _idx);
		Top8Super.Top8SuperBuilder addA1Field(List a1Field2);
		Top8Super.Top8SuperBuilder setA1Field(List a1Field3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("a1Field"), processor, A8_1.A8_1Builder.class, getA1Field());
		}
		

		Top8Super.Top8SuperBuilder prune();
	}

	/*********************** Immutable Implementation of Top8Super  ***********************/
	class Top8SuperImpl implements Top8Super {
		private final List a1Field;
		
		protected Top8SuperImpl(Top8Super.Top8SuperBuilder builder) {
			this.a1Field = ofNullable(builder.getA1Field()).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("a1Field")
		public List getA1Field() {
			return a1Field;
		}
		
		@Override
		public Top8Super build() {
			return this;
		}
		
		@Override
		public Top8Super.Top8SuperBuilder toBuilder() {
			Top8Super.Top8SuperBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Top8Super.Top8SuperBuilder builder) {
			ofNullable(getA1Field()).ifPresent(builder::setA1Field);
		}

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

	/*********************** Builder Implementation of Top8Super  ***********************/
	class Top8SuperBuilderImpl implements Top8Super.Top8SuperBuilder {
	
		protected List a1Field = new ArrayList<>();
	
		public Top8SuperBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("a1Field")
		public List getA1Field() {
			return a1Field;
		}
		
		public A8_1.A8_1Builder getOrCreateA1Field(int _index) {
		
			if (a1Field==null) {
				this.a1Field = new ArrayList<>();
			}
			A8_1.A8_1Builder result;
			return getIndex(a1Field, _index, () -> {
						A8_1.A8_1Builder newA1Field = A8_1.builder();
						return newA1Field;
					});
		}
		
		@Override
		public Top8Super.Top8SuperBuilder addA1Field(A8_1 a1Field) {
			if (a1Field!=null) this.a1Field.add(a1Field.toBuilder());
			return this;
		}
		
		@Override
		public Top8Super.Top8SuperBuilder addA1Field(A8_1 a1Field, int _idx) {
			getIndex(this.a1Field, _idx, () -> a1Field.toBuilder());
			return this;
		}
		@Override 
		public Top8Super.Top8SuperBuilder addA1Field(List a1Fields) {
			if (a1Fields != null) {
				for (A8_1 toAdd : a1Fields) {
					this.a1Field.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("a1Field")
		public Top8Super.Top8SuperBuilder setA1Field(List a1Fields) {
			if (a1Fields == null)  {
				this.a1Field = new ArrayList<>();
			}
			else {
				this.a1Field = a1Fields.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public Top8Super build() {
			return new Top8Super.Top8SuperImpl(this);
		}
		
		@Override
		public Top8Super.Top8SuperBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top8Super.Top8SuperBuilder prune() {
			a1Field = a1Field.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getA1Field()!=null && getA1Field().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Top8Super.Top8SuperBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Top8Super.Top8SuperBuilder o = (Top8Super.Top8SuperBuilder) other;
			
			merger.mergeRosetta(getA1Field(), o.getA1Field(), this::getOrCreateA1Field);
			
			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;
		
			Top8Super _that = getType().cast(o);
		
			if (!ListEquals.listEquals(a1Field, _that.getA1Field())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (a1Field != null ? a1Field.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Top8SuperBuilder {" +
				"a1Field=" + this.a1Field +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy