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

org.isda.cdm.Parent Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package org.isda.cdm;

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.model.metafields.ReferenceWithMetaString;
import com.rosetta.model.metafields.ReferenceWithMetaString.ReferenceWithMetaStringBuilder;
import com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.isda.cdm.AnotherMiddle;
import org.isda.cdm.Flat;
import org.isda.cdm.Middle;
import org.isda.cdm.Parent;
import org.isda.cdm.Parent.ParentBuilder;
import org.isda.cdm.Parent.ParentBuilderImpl;
import org.isda.cdm.Parent.ParentImpl;
import org.isda.cdm.meta.ParentMeta;

import static java.util.Optional.ofNullable;

/**
 * @version test
 */
@RosettaDataType(value="Parent", builder=Parent.ParentBuilderImpl.class, version="test")
public interface Parent extends RosettaModelObject {

	ParentMeta metaData = new ParentMeta();

	/*********************** Getter Methods  ***********************/
	Flat getParentFieldOne();
	List getParentFieldTwo();
	String getParentFieldThree();
	List getParentFieldFour();
	ReferenceWithMetaString getParentFieldFiveReference();
	Flat getParentFieldSix();
	List getRepeatedField();
	Middle getParentFieldSeven();
	AnotherMiddle getParentFieldEight();

	/*********************** Build Methods  ***********************/
	Parent build();
	
	Parent.ParentBuilder toBuilder();
	
	static Parent.ParentBuilder builder() {
		return new Parent.ParentBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Parent.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("parentFieldOne"), processor, Flat.class, getParentFieldOne());
		processRosetta(path.newSubPath("parentFieldTwo"), processor, Flat.class, getParentFieldTwo());
		processor.processBasic(path.newSubPath("parentFieldThree"), String.class, getParentFieldThree(), this);
		processor.processBasic(path.newSubPath("parentFieldFour"), String.class, getParentFieldFour(), this);
		processRosetta(path.newSubPath("parentFieldFiveReference"), processor, ReferenceWithMetaString.class, getParentFieldFiveReference());
		processRosetta(path.newSubPath("parentFieldSix"), processor, Flat.class, getParentFieldSix());
		processRosetta(path.newSubPath("repeatedField"), processor, Flat.class, getRepeatedField());
		processRosetta(path.newSubPath("parentFieldSeven"), processor, Middle.class, getParentFieldSeven());
		processRosetta(path.newSubPath("parentFieldEight"), processor, AnotherMiddle.class, getParentFieldEight());
	}
	

	/*********************** Builder Interface  ***********************/
	interface ParentBuilder extends Parent, RosettaModelObjectBuilder {
		Flat.FlatBuilder getOrCreateParentFieldOne();
		Flat.FlatBuilder getParentFieldOne();
		Flat.FlatBuilder getOrCreateParentFieldTwo(int _index);
		List getParentFieldTwo();
		ReferenceWithMetaString.ReferenceWithMetaStringBuilder getOrCreateParentFieldFiveReference();
		ReferenceWithMetaString.ReferenceWithMetaStringBuilder getParentFieldFiveReference();
		Flat.FlatBuilder getOrCreateParentFieldSix();
		Flat.FlatBuilder getParentFieldSix();
		Flat.FlatBuilder getOrCreateRepeatedField(int _index);
		List getRepeatedField();
		Middle.MiddleBuilder getOrCreateParentFieldSeven();
		Middle.MiddleBuilder getParentFieldSeven();
		AnotherMiddle.AnotherMiddleBuilder getOrCreateParentFieldEight();
		AnotherMiddle.AnotherMiddleBuilder getParentFieldEight();
		Parent.ParentBuilder setParentFieldOne(Flat parentFieldOne);
		Parent.ParentBuilder addParentFieldTwo(Flat parentFieldTwo0);
		Parent.ParentBuilder addParentFieldTwo(Flat parentFieldTwo1, int _idx);
		Parent.ParentBuilder addParentFieldTwo(List parentFieldTwo2);
		Parent.ParentBuilder setParentFieldTwo(List parentFieldTwo3);
		Parent.ParentBuilder setParentFieldThree(String parentFieldThree);
		Parent.ParentBuilder addParentFieldFour(String parentFieldFour0);
		Parent.ParentBuilder addParentFieldFour(String parentFieldFour1, int _idx);
		Parent.ParentBuilder addParentFieldFour(List parentFieldFour2);
		Parent.ParentBuilder setParentFieldFour(List parentFieldFour3);
		Parent.ParentBuilder setParentFieldFiveReference(ReferenceWithMetaString parentFieldFiveReference0);
		Parent.ParentBuilder setParentFieldFiveReferenceValue(String parentFieldFiveReference1);
		Parent.ParentBuilder setParentFieldSix(Flat parentFieldSix);
		Parent.ParentBuilder addRepeatedField(Flat repeatedField0);
		Parent.ParentBuilder addRepeatedField(Flat repeatedField1, int _idx);
		Parent.ParentBuilder addRepeatedField(List repeatedField2);
		Parent.ParentBuilder setRepeatedField(List repeatedField3);
		Parent.ParentBuilder setParentFieldSeven(Middle parentFieldSeven);
		Parent.ParentBuilder setParentFieldEight(AnotherMiddle parentFieldEight);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("parentFieldOne"), processor, Flat.FlatBuilder.class, getParentFieldOne());
			processRosetta(path.newSubPath("parentFieldTwo"), processor, Flat.FlatBuilder.class, getParentFieldTwo());
			processor.processBasic(path.newSubPath("parentFieldThree"), String.class, getParentFieldThree(), this);
			processor.processBasic(path.newSubPath("parentFieldFour"), String.class, getParentFieldFour(), this);
			processRosetta(path.newSubPath("parentFieldFiveReference"), processor, ReferenceWithMetaString.ReferenceWithMetaStringBuilder.class, getParentFieldFiveReference());
			processRosetta(path.newSubPath("parentFieldSix"), processor, Flat.FlatBuilder.class, getParentFieldSix());
			processRosetta(path.newSubPath("repeatedField"), processor, Flat.FlatBuilder.class, getRepeatedField());
			processRosetta(path.newSubPath("parentFieldSeven"), processor, Middle.MiddleBuilder.class, getParentFieldSeven());
			processRosetta(path.newSubPath("parentFieldEight"), processor, AnotherMiddle.AnotherMiddleBuilder.class, getParentFieldEight());
		}
		

		Parent.ParentBuilder prune();
	}

	/*********************** Immutable Implementation of Parent  ***********************/
	class ParentImpl implements Parent {
		private final Flat parentFieldOne;
		private final List parentFieldTwo;
		private final String parentFieldThree;
		private final List parentFieldFour;
		private final ReferenceWithMetaString parentFieldFiveReference;
		private final Flat parentFieldSix;
		private final List repeatedField;
		private final Middle parentFieldSeven;
		private final AnotherMiddle parentFieldEight;
		
		protected ParentImpl(Parent.ParentBuilder builder) {
			this.parentFieldOne = ofNullable(builder.getParentFieldOne()).map(f->f.build()).orElse(null);
			this.parentFieldTwo = ofNullable(builder.getParentFieldTwo()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
			this.parentFieldThree = builder.getParentFieldThree();
			this.parentFieldFour = ofNullable(builder.getParentFieldFour()).filter(_l->!_l.isEmpty()).map(ImmutableList::copyOf).orElse(null);
			this.parentFieldFiveReference = ofNullable(builder.getParentFieldFiveReference()).map(f->f.build()).orElse(null);
			this.parentFieldSix = ofNullable(builder.getParentFieldSix()).map(f->f.build()).orElse(null);
			this.repeatedField = ofNullable(builder.getRepeatedField()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
			this.parentFieldSeven = ofNullable(builder.getParentFieldSeven()).map(f->f.build()).orElse(null);
			this.parentFieldEight = ofNullable(builder.getParentFieldEight()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("parentFieldOne")
		public Flat getParentFieldOne() {
			return parentFieldOne;
		}
		
		@Override
		@RosettaAttribute("parentFieldTwo")
		public List getParentFieldTwo() {
			return parentFieldTwo;
		}
		
		@Override
		@RosettaAttribute("parentFieldThree")
		public String getParentFieldThree() {
			return parentFieldThree;
		}
		
		@Override
		@RosettaAttribute("parentFieldFour")
		public List getParentFieldFour() {
			return parentFieldFour;
		}
		
		@Override
		@RosettaAttribute("parentFieldFiveReference")
		public ReferenceWithMetaString getParentFieldFiveReference() {
			return parentFieldFiveReference;
		}
		
		@Override
		@RosettaAttribute("parentFieldSix")
		public Flat getParentFieldSix() {
			return parentFieldSix;
		}
		
		@Override
		@RosettaAttribute("repeatedField")
		public List getRepeatedField() {
			return repeatedField;
		}
		
		@Override
		@RosettaAttribute("parentFieldSeven")
		public Middle getParentFieldSeven() {
			return parentFieldSeven;
		}
		
		@Override
		@RosettaAttribute("parentFieldEight")
		public AnotherMiddle getParentFieldEight() {
			return parentFieldEight;
		}
		
		@Override
		public Parent build() {
			return this;
		}
		
		@Override
		public Parent.ParentBuilder toBuilder() {
			Parent.ParentBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Parent.ParentBuilder builder) {
			ofNullable(getParentFieldOne()).ifPresent(builder::setParentFieldOne);
			ofNullable(getParentFieldTwo()).ifPresent(builder::setParentFieldTwo);
			ofNullable(getParentFieldThree()).ifPresent(builder::setParentFieldThree);
			ofNullable(getParentFieldFour()).ifPresent(builder::setParentFieldFour);
			ofNullable(getParentFieldFiveReference()).ifPresent(builder::setParentFieldFiveReference);
			ofNullable(getParentFieldSix()).ifPresent(builder::setParentFieldSix);
			ofNullable(getRepeatedField()).ifPresent(builder::setRepeatedField);
			ofNullable(getParentFieldSeven()).ifPresent(builder::setParentFieldSeven);
			ofNullable(getParentFieldEight()).ifPresent(builder::setParentFieldEight);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			Parent _that = getType().cast(o);
		
			if (!Objects.equals(parentFieldOne, _that.getParentFieldOne())) return false;
			if (!ListEquals.listEquals(parentFieldTwo, _that.getParentFieldTwo())) return false;
			if (!Objects.equals(parentFieldThree, _that.getParentFieldThree())) return false;
			if (!ListEquals.listEquals(parentFieldFour, _that.getParentFieldFour())) return false;
			if (!Objects.equals(parentFieldFiveReference, _that.getParentFieldFiveReference())) return false;
			if (!Objects.equals(parentFieldSix, _that.getParentFieldSix())) return false;
			if (!ListEquals.listEquals(repeatedField, _that.getRepeatedField())) return false;
			if (!Objects.equals(parentFieldSeven, _that.getParentFieldSeven())) return false;
			if (!Objects.equals(parentFieldEight, _that.getParentFieldEight())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (parentFieldOne != null ? parentFieldOne.hashCode() : 0);
			_result = 31 * _result + (parentFieldTwo != null ? parentFieldTwo.hashCode() : 0);
			_result = 31 * _result + (parentFieldThree != null ? parentFieldThree.hashCode() : 0);
			_result = 31 * _result + (parentFieldFour != null ? parentFieldFour.hashCode() : 0);
			_result = 31 * _result + (parentFieldFiveReference != null ? parentFieldFiveReference.hashCode() : 0);
			_result = 31 * _result + (parentFieldSix != null ? parentFieldSix.hashCode() : 0);
			_result = 31 * _result + (repeatedField != null ? repeatedField.hashCode() : 0);
			_result = 31 * _result + (parentFieldSeven != null ? parentFieldSeven.hashCode() : 0);
			_result = 31 * _result + (parentFieldEight != null ? parentFieldEight.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Parent {" +
				"parentFieldOne=" + this.parentFieldOne + ", " +
				"parentFieldTwo=" + this.parentFieldTwo + ", " +
				"parentFieldThree=" + this.parentFieldThree + ", " +
				"parentFieldFour=" + this.parentFieldFour + ", " +
				"parentFieldFiveReference=" + this.parentFieldFiveReference + ", " +
				"parentFieldSix=" + this.parentFieldSix + ", " +
				"repeatedField=" + this.repeatedField + ", " +
				"parentFieldSeven=" + this.parentFieldSeven + ", " +
				"parentFieldEight=" + this.parentFieldEight +
			'}';
		}
	}

	/*********************** Builder Implementation of Parent  ***********************/
	class ParentBuilderImpl implements Parent.ParentBuilder {
	
		protected Flat.FlatBuilder parentFieldOne;
		protected List parentFieldTwo = new ArrayList<>();
		protected String parentFieldThree;
		protected List parentFieldFour = new ArrayList<>();
		protected ReferenceWithMetaString.ReferenceWithMetaStringBuilder parentFieldFiveReference;
		protected Flat.FlatBuilder parentFieldSix;
		protected List repeatedField = new ArrayList<>();
		protected Middle.MiddleBuilder parentFieldSeven;
		protected AnotherMiddle.AnotherMiddleBuilder parentFieldEight;
	
		public ParentBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("parentFieldOne")
		public Flat.FlatBuilder getParentFieldOne() {
			return parentFieldOne;
		}
		
		@Override
		public Flat.FlatBuilder getOrCreateParentFieldOne() {
			Flat.FlatBuilder result;
			if (parentFieldOne!=null) {
				result = parentFieldOne;
			}
			else {
				result = parentFieldOne = Flat.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("parentFieldTwo")
		public List getParentFieldTwo() {
			return parentFieldTwo;
		}
		
		public Flat.FlatBuilder getOrCreateParentFieldTwo(int _index) {
		
			if (parentFieldTwo==null) {
				this.parentFieldTwo = new ArrayList<>();
			}
			Flat.FlatBuilder result;
			return getIndex(parentFieldTwo, _index, () -> {
						Flat.FlatBuilder newParentFieldTwo = Flat.builder();
						return newParentFieldTwo;
					});
		}
		
		@Override
		@RosettaAttribute("parentFieldThree")
		public String getParentFieldThree() {
			return parentFieldThree;
		}
		
		@Override
		@RosettaAttribute("parentFieldFour")
		public List getParentFieldFour() {
			return parentFieldFour;
		}
		
		@Override
		@RosettaAttribute("parentFieldFiveReference")
		public ReferenceWithMetaString.ReferenceWithMetaStringBuilder getParentFieldFiveReference() {
			return parentFieldFiveReference;
		}
		
		@Override
		public ReferenceWithMetaString.ReferenceWithMetaStringBuilder getOrCreateParentFieldFiveReference() {
			ReferenceWithMetaString.ReferenceWithMetaStringBuilder result;
			if (parentFieldFiveReference!=null) {
				result = parentFieldFiveReference;
			}
			else {
				result = parentFieldFiveReference = ReferenceWithMetaString.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("parentFieldSix")
		public Flat.FlatBuilder getParentFieldSix() {
			return parentFieldSix;
		}
		
		@Override
		public Flat.FlatBuilder getOrCreateParentFieldSix() {
			Flat.FlatBuilder result;
			if (parentFieldSix!=null) {
				result = parentFieldSix;
			}
			else {
				result = parentFieldSix = Flat.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("repeatedField")
		public List getRepeatedField() {
			return repeatedField;
		}
		
		public Flat.FlatBuilder getOrCreateRepeatedField(int _index) {
		
			if (repeatedField==null) {
				this.repeatedField = new ArrayList<>();
			}
			Flat.FlatBuilder result;
			return getIndex(repeatedField, _index, () -> {
						Flat.FlatBuilder newRepeatedField = Flat.builder();
						return newRepeatedField;
					});
		}
		
		@Override
		@RosettaAttribute("parentFieldSeven")
		public Middle.MiddleBuilder getParentFieldSeven() {
			return parentFieldSeven;
		}
		
		@Override
		public Middle.MiddleBuilder getOrCreateParentFieldSeven() {
			Middle.MiddleBuilder result;
			if (parentFieldSeven!=null) {
				result = parentFieldSeven;
			}
			else {
				result = parentFieldSeven = Middle.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("parentFieldEight")
		public AnotherMiddle.AnotherMiddleBuilder getParentFieldEight() {
			return parentFieldEight;
		}
		
		@Override
		public AnotherMiddle.AnotherMiddleBuilder getOrCreateParentFieldEight() {
			AnotherMiddle.AnotherMiddleBuilder result;
			if (parentFieldEight!=null) {
				result = parentFieldEight;
			}
			else {
				result = parentFieldEight = AnotherMiddle.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("parentFieldOne")
		public Parent.ParentBuilder setParentFieldOne(Flat parentFieldOne) {
			this.parentFieldOne = parentFieldOne==null?null:parentFieldOne.toBuilder();
			return this;
		}
		@Override
		public Parent.ParentBuilder addParentFieldTwo(Flat parentFieldTwo) {
			if (parentFieldTwo!=null) this.parentFieldTwo.add(parentFieldTwo.toBuilder());
			return this;
		}
		
		@Override
		public Parent.ParentBuilder addParentFieldTwo(Flat parentFieldTwo, int _idx) {
			getIndex(this.parentFieldTwo, _idx, () -> parentFieldTwo.toBuilder());
			return this;
		}
		@Override 
		public Parent.ParentBuilder addParentFieldTwo(List parentFieldTwos) {
			if (parentFieldTwos != null) {
				for (Flat toAdd : parentFieldTwos) {
					this.parentFieldTwo.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("parentFieldTwo")
		public Parent.ParentBuilder setParentFieldTwo(List parentFieldTwos) {
			if (parentFieldTwos == null)  {
				this.parentFieldTwo = new ArrayList<>();
			}
			else {
				this.parentFieldTwo = parentFieldTwos.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		@RosettaAttribute("parentFieldThree")
		public Parent.ParentBuilder setParentFieldThree(String parentFieldThree) {
			this.parentFieldThree = parentFieldThree==null?null:parentFieldThree;
			return this;
		}
		@Override
		public Parent.ParentBuilder addParentFieldFour(String parentFieldFour) {
			if (parentFieldFour!=null) this.parentFieldFour.add(parentFieldFour);
			return this;
		}
		
		@Override
		public Parent.ParentBuilder addParentFieldFour(String parentFieldFour, int _idx) {
			getIndex(this.parentFieldFour, _idx, () -> parentFieldFour);
			return this;
		}
		@Override 
		public Parent.ParentBuilder addParentFieldFour(List parentFieldFours) {
			if (parentFieldFours != null) {
				for (String toAdd : parentFieldFours) {
					this.parentFieldFour.add(toAdd);
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("parentFieldFour")
		public Parent.ParentBuilder setParentFieldFour(List parentFieldFours) {
			if (parentFieldFours == null)  {
				this.parentFieldFour = new ArrayList<>();
			}
			else {
				this.parentFieldFour = parentFieldFours.stream()
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		@RosettaAttribute("parentFieldFiveReference")
		public Parent.ParentBuilder setParentFieldFiveReference(ReferenceWithMetaString parentFieldFiveReference) {
			this.parentFieldFiveReference = parentFieldFiveReference==null?null:parentFieldFiveReference.toBuilder();
			return this;
		}
		@Override
		public Parent.ParentBuilder setParentFieldFiveReferenceValue(String parentFieldFiveReference) {
			this.getOrCreateParentFieldFiveReference().setValue(parentFieldFiveReference);
			return this;
		}
		@Override
		@RosettaAttribute("parentFieldSix")
		public Parent.ParentBuilder setParentFieldSix(Flat parentFieldSix) {
			this.parentFieldSix = parentFieldSix==null?null:parentFieldSix.toBuilder();
			return this;
		}
		@Override
		public Parent.ParentBuilder addRepeatedField(Flat repeatedField) {
			if (repeatedField!=null) this.repeatedField.add(repeatedField.toBuilder());
			return this;
		}
		
		@Override
		public Parent.ParentBuilder addRepeatedField(Flat repeatedField, int _idx) {
			getIndex(this.repeatedField, _idx, () -> repeatedField.toBuilder());
			return this;
		}
		@Override 
		public Parent.ParentBuilder addRepeatedField(List repeatedFields) {
			if (repeatedFields != null) {
				for (Flat toAdd : repeatedFields) {
					this.repeatedField.add(toAdd.toBuilder());
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("repeatedField")
		public Parent.ParentBuilder setRepeatedField(List repeatedFields) {
			if (repeatedFields == null)  {
				this.repeatedField = new ArrayList<>();
			}
			else {
				this.repeatedField = repeatedFields.stream()
					.map(_a->_a.toBuilder())
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		@Override
		@RosettaAttribute("parentFieldSeven")
		public Parent.ParentBuilder setParentFieldSeven(Middle parentFieldSeven) {
			this.parentFieldSeven = parentFieldSeven==null?null:parentFieldSeven.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("parentFieldEight")
		public Parent.ParentBuilder setParentFieldEight(AnotherMiddle parentFieldEight) {
			this.parentFieldEight = parentFieldEight==null?null:parentFieldEight.toBuilder();
			return this;
		}
		
		@Override
		public Parent build() {
			return new Parent.ParentImpl(this);
		}
		
		@Override
		public Parent.ParentBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Parent.ParentBuilder prune() {
			if (parentFieldOne!=null && !parentFieldOne.prune().hasData()) parentFieldOne = null;
			parentFieldTwo = parentFieldTwo.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			if (parentFieldFiveReference!=null && !parentFieldFiveReference.prune().hasData()) parentFieldFiveReference = null;
			if (parentFieldSix!=null && !parentFieldSix.prune().hasData()) parentFieldSix = null;
			repeatedField = repeatedField.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
			if (parentFieldSeven!=null && !parentFieldSeven.prune().hasData()) parentFieldSeven = null;
			if (parentFieldEight!=null && !parentFieldEight.prune().hasData()) parentFieldEight = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getParentFieldOne()!=null && getParentFieldOne().hasData()) return true;
			if (getParentFieldTwo()!=null && getParentFieldTwo().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			if (getParentFieldThree()!=null) return true;
			if (getParentFieldFour()!=null && !getParentFieldFour().isEmpty()) return true;
			if (getParentFieldFiveReference()!=null) return true;
			if (getParentFieldSix()!=null && getParentFieldSix().hasData()) return true;
			if (getRepeatedField()!=null && getRepeatedField().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
			if (getParentFieldSeven()!=null && getParentFieldSeven().hasData()) return true;
			if (getParentFieldEight()!=null && getParentFieldEight().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Parent.ParentBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Parent.ParentBuilder o = (Parent.ParentBuilder) other;
			
			merger.mergeRosetta(getParentFieldOne(), o.getParentFieldOne(), this::setParentFieldOne);
			merger.mergeRosetta(getParentFieldTwo(), o.getParentFieldTwo(), this::getOrCreateParentFieldTwo);
			merger.mergeRosetta(getParentFieldFiveReference(), o.getParentFieldFiveReference(), this::setParentFieldFiveReference);
			merger.mergeRosetta(getParentFieldSix(), o.getParentFieldSix(), this::setParentFieldSix);
			merger.mergeRosetta(getRepeatedField(), o.getRepeatedField(), this::getOrCreateRepeatedField);
			merger.mergeRosetta(getParentFieldSeven(), o.getParentFieldSeven(), this::setParentFieldSeven);
			merger.mergeRosetta(getParentFieldEight(), o.getParentFieldEight(), this::setParentFieldEight);
			
			merger.mergeBasic(getParentFieldThree(), o.getParentFieldThree(), this::setParentFieldThree);
			merger.mergeBasic(getParentFieldFour(), o.getParentFieldFour(), (Consumer) this::addParentFieldFour);
			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;
		
			Parent _that = getType().cast(o);
		
			if (!Objects.equals(parentFieldOne, _that.getParentFieldOne())) return false;
			if (!ListEquals.listEquals(parentFieldTwo, _that.getParentFieldTwo())) return false;
			if (!Objects.equals(parentFieldThree, _that.getParentFieldThree())) return false;
			if (!ListEquals.listEquals(parentFieldFour, _that.getParentFieldFour())) return false;
			if (!Objects.equals(parentFieldFiveReference, _that.getParentFieldFiveReference())) return false;
			if (!Objects.equals(parentFieldSix, _that.getParentFieldSix())) return false;
			if (!ListEquals.listEquals(repeatedField, _that.getRepeatedField())) return false;
			if (!Objects.equals(parentFieldSeven, _that.getParentFieldSeven())) return false;
			if (!Objects.equals(parentFieldEight, _that.getParentFieldEight())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (parentFieldOne != null ? parentFieldOne.hashCode() : 0);
			_result = 31 * _result + (parentFieldTwo != null ? parentFieldTwo.hashCode() : 0);
			_result = 31 * _result + (parentFieldThree != null ? parentFieldThree.hashCode() : 0);
			_result = 31 * _result + (parentFieldFour != null ? parentFieldFour.hashCode() : 0);
			_result = 31 * _result + (parentFieldFiveReference != null ? parentFieldFiveReference.hashCode() : 0);
			_result = 31 * _result + (parentFieldSix != null ? parentFieldSix.hashCode() : 0);
			_result = 31 * _result + (repeatedField != null ? repeatedField.hashCode() : 0);
			_result = 31 * _result + (parentFieldSeven != null ? parentFieldSeven.hashCode() : 0);
			_result = 31 * _result + (parentFieldEight != null ? parentFieldEight.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "ParentBuilder {" +
				"parentFieldOne=" + this.parentFieldOne + ", " +
				"parentFieldTwo=" + this.parentFieldTwo + ", " +
				"parentFieldThree=" + this.parentFieldThree + ", " +
				"parentFieldFour=" + this.parentFieldFour + ", " +
				"parentFieldFiveReference=" + this.parentFieldFiveReference + ", " +
				"parentFieldSix=" + this.parentFieldSix + ", " +
				"repeatedField=" + this.repeatedField + ", " +
				"parentFieldSeven=" + this.parentFieldSeven + ", " +
				"parentFieldEight=" + this.parentFieldEight +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy