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

com.rosetta.teststruct.model.StructTop11 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.teststruct.model;

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.teststruct.model.StructA11;
import com.rosetta.teststruct.model.StructTop11;
import com.rosetta.teststruct.model.StructTop11.StructTop11Builder;
import com.rosetta.teststruct.model.StructTop11.StructTop11BuilderImpl;
import com.rosetta.teststruct.model.StructTop11.StructTop11Impl;
import com.rosetta.teststruct.model.meta.StructTop11Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	StructTop11Meta metaData = new StructTop11Meta();

	/*********************** Getter Methods  ***********************/
	StructA11 getAField();

	/*********************** Build Methods  ***********************/
	StructTop11 build();
	
	StructTop11.StructTop11Builder toBuilder();
	
	static StructTop11.StructTop11Builder builder() {
		return new StructTop11.StructTop11BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return StructTop11.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("aField"), processor, StructA11.class, getAField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface StructTop11Builder extends StructTop11, RosettaModelObjectBuilder {
		StructA11.StructA11Builder getOrCreateAField();
		StructA11.StructA11Builder getAField();
		StructTop11.StructTop11Builder setAField(StructA11 aField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("aField"), processor, StructA11.StructA11Builder.class, getAField());
		}
		

		StructTop11.StructTop11Builder prune();
	}

	/*********************** Immutable Implementation of StructTop11  ***********************/
	class StructTop11Impl implements StructTop11 {
		private final StructA11 aField;
		
		protected StructTop11Impl(StructTop11.StructTop11Builder builder) {
			this.aField = ofNullable(builder.getAField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("aField")
		public StructA11 getAField() {
			return aField;
		}
		
		@Override
		public StructTop11 build() {
			return this;
		}
		
		@Override
		public StructTop11.StructTop11Builder toBuilder() {
			StructTop11.StructTop11Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(StructTop11.StructTop11Builder builder) {
			ofNullable(getAField()).ifPresent(builder::setAField);
		}

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

	/*********************** Builder Implementation of StructTop11  ***********************/
	class StructTop11BuilderImpl implements StructTop11.StructTop11Builder {
	
		protected StructA11.StructA11Builder aField;
	
		public StructTop11BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("aField")
		public StructA11.StructA11Builder getAField() {
			return aField;
		}
		
		@Override
		public StructA11.StructA11Builder getOrCreateAField() {
			StructA11.StructA11Builder result;
			if (aField!=null) {
				result = aField;
			}
			else {
				result = aField = StructA11.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("aField")
		public StructTop11.StructTop11Builder setAField(StructA11 aField) {
			this.aField = aField==null?null:aField.toBuilder();
			return this;
		}
		
		@Override
		public StructTop11 build() {
			return new StructTop11.StructTop11Impl(this);
		}
		
		@Override
		public StructTop11.StructTop11Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public StructTop11.StructTop11Builder prune() {
			if (aField!=null && !aField.prune().hasData()) aField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getAField()!=null && getAField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public StructTop11.StructTop11Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			StructTop11.StructTop11Builder o = (StructTop11.StructTop11Builder) other;
			
			merger.mergeRosetta(getAField(), o.getAField(), this::setAField);
			
			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;
		
			StructTop11 _that = getType().cast(o);
		
			if (!Objects.equals(aField, _that.getAField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (aField != null ? aField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "StructTop11Builder {" +
				"aField=" + this.aField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy