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

com.rosetta.teststruct.model.A4 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.A4;
import com.rosetta.teststruct.model.A4.A4Builder;
import com.rosetta.teststruct.model.A4.A4BuilderImpl;
import com.rosetta.teststruct.model.A4.A4Impl;
import com.rosetta.teststruct.model.C4;
import com.rosetta.teststruct.model.E4;
import com.rosetta.teststruct.model.meta.A4Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	A4Meta metaData = new A4Meta();

	/*********************** Getter Methods  ***********************/
	String getDField();
	C4 getCField();
	E4 getEField();

	/*********************** Build Methods  ***********************/
	A4 build();
	
	A4.A4Builder toBuilder();
	
	static A4.A4Builder builder() {
		return new A4.A4BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return A4.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("dField"), String.class, getDField(), this);
		processRosetta(path.newSubPath("cField"), processor, C4.class, getCField());
		processRosetta(path.newSubPath("eField"), processor, E4.class, getEField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface A4Builder extends A4, RosettaModelObjectBuilder {
		C4.C4Builder getOrCreateCField();
		C4.C4Builder getCField();
		E4.E4Builder getOrCreateEField();
		E4.E4Builder getEField();
		A4.A4Builder setDField(String dField);
		A4.A4Builder setCField(C4 cField);
		A4.A4Builder setEField(E4 eField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("dField"), String.class, getDField(), this);
			processRosetta(path.newSubPath("cField"), processor, C4.C4Builder.class, getCField());
			processRosetta(path.newSubPath("eField"), processor, E4.E4Builder.class, getEField());
		}
		

		A4.A4Builder prune();
	}

	/*********************** Immutable Implementation of A4  ***********************/
	class A4Impl implements A4 {
		private final String dField;
		private final C4 cField;
		private final E4 eField;
		
		protected A4Impl(A4.A4Builder builder) {
			this.dField = builder.getDField();
			this.cField = ofNullable(builder.getCField()).map(f->f.build()).orElse(null);
			this.eField = ofNullable(builder.getEField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("dField")
		public String getDField() {
			return dField;
		}
		
		@Override
		@RosettaAttribute("cField")
		public C4 getCField() {
			return cField;
		}
		
		@Override
		@RosettaAttribute("eField")
		public E4 getEField() {
			return eField;
		}
		
		@Override
		public A4 build() {
			return this;
		}
		
		@Override
		public A4.A4Builder toBuilder() {
			A4.A4Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(A4.A4Builder builder) {
			ofNullable(getDField()).ifPresent(builder::setDField);
			ofNullable(getCField()).ifPresent(builder::setCField);
			ofNullable(getEField()).ifPresent(builder::setEField);
		}

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

	/*********************** Builder Implementation of A4  ***********************/
	class A4BuilderImpl implements A4.A4Builder {
	
		protected String dField;
		protected C4.C4Builder cField;
		protected E4.E4Builder eField;
	
		public A4BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("dField")
		public String getDField() {
			return dField;
		}
		
		@Override
		@RosettaAttribute("cField")
		public C4.C4Builder getCField() {
			return cField;
		}
		
		@Override
		public C4.C4Builder getOrCreateCField() {
			C4.C4Builder result;
			if (cField!=null) {
				result = cField;
			}
			else {
				result = cField = C4.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("eField")
		public E4.E4Builder getEField() {
			return eField;
		}
		
		@Override
		public E4.E4Builder getOrCreateEField() {
			E4.E4Builder result;
			if (eField!=null) {
				result = eField;
			}
			else {
				result = eField = E4.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("dField")
		public A4.A4Builder setDField(String dField) {
			this.dField = dField==null?null:dField;
			return this;
		}
		@Override
		@RosettaAttribute("cField")
		public A4.A4Builder setCField(C4 cField) {
			this.cField = cField==null?null:cField.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("eField")
		public A4.A4Builder setEField(E4 eField) {
			this.eField = eField==null?null:eField.toBuilder();
			return this;
		}
		
		@Override
		public A4 build() {
			return new A4.A4Impl(this);
		}
		
		@Override
		public A4.A4Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A4.A4Builder prune() {
			if (cField!=null && !cField.prune().hasData()) cField = null;
			if (eField!=null && !eField.prune().hasData()) eField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getDField()!=null) return true;
			if (getCField()!=null && getCField().hasData()) return true;
			if (getEField()!=null && getEField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A4.A4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			A4.A4Builder o = (A4.A4Builder) other;
			
			merger.mergeRosetta(getCField(), o.getCField(), this::setCField);
			merger.mergeRosetta(getEField(), o.getEField(), this::setEField);
			
			merger.mergeBasic(getDField(), o.getDField(), this::setDField);
			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;
		
			A4 _that = getType().cast(o);
		
			if (!Objects.equals(dField, _that.getDField())) return false;
			if (!Objects.equals(cField, _that.getCField())) return false;
			if (!Objects.equals(eField, _that.getEField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (dField != null ? dField.hashCode() : 0);
			_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
			_result = 31 * _result + (eField != null ? eField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "A4Builder {" +
				"dField=" + this.dField + ", " +
				"cField=" + this.cField + ", " +
				"eField=" + this.eField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy