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

com.rosetta.testconditional.model.C22 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testconditional.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.testconditional.model.C22;
import com.rosetta.testconditional.model.C22.C22Builder;
import com.rosetta.testconditional.model.C22.C22BuilderImpl;
import com.rosetta.testconditional.model.C22.C22Impl;
import com.rosetta.testconditional.model.D22;
import com.rosetta.testconditional.model.TestEnum;
import com.rosetta.testconditional.model.meta.C22Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	C22Meta metaData = new C22Meta();

	/*********************** Getter Methods  ***********************/
	TestEnum getCEnum();
	D22 getDField();

	/*********************** Build Methods  ***********************/
	C22 build();
	
	C22.C22Builder toBuilder();
	
	static C22.C22Builder builder() {
		return new C22.C22BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return C22.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("cEnum"), TestEnum.class, getCEnum(), this);
		processRosetta(path.newSubPath("dField"), processor, D22.class, getDField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface C22Builder extends C22, RosettaModelObjectBuilder {
		D22.D22Builder getOrCreateDField();
		D22.D22Builder getDField();
		C22.C22Builder setCEnum(TestEnum cEnum);
		C22.C22Builder setDField(D22 dField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("cEnum"), TestEnum.class, getCEnum(), this);
			processRosetta(path.newSubPath("dField"), processor, D22.D22Builder.class, getDField());
		}
		

		C22.C22Builder prune();
	}

	/*********************** Immutable Implementation of C22  ***********************/
	class C22Impl implements C22 {
		private final TestEnum cEnum;
		private final D22 dField;
		
		protected C22Impl(C22.C22Builder builder) {
			this.cEnum = builder.getCEnum();
			this.dField = ofNullable(builder.getDField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("cEnum")
		public TestEnum getCEnum() {
			return cEnum;
		}
		
		@Override
		@RosettaAttribute("dField")
		public D22 getDField() {
			return dField;
		}
		
		@Override
		public C22 build() {
			return this;
		}
		
		@Override
		public C22.C22Builder toBuilder() {
			C22.C22Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(C22.C22Builder builder) {
			ofNullable(getCEnum()).ifPresent(builder::setCEnum);
			ofNullable(getDField()).ifPresent(builder::setDField);
		}

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

	/*********************** Builder Implementation of C22  ***********************/
	class C22BuilderImpl implements C22.C22Builder {
	
		protected TestEnum cEnum;
		protected D22.D22Builder dField;
	
		public C22BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("cEnum")
		public TestEnum getCEnum() {
			return cEnum;
		}
		
		@Override
		@RosettaAttribute("dField")
		public D22.D22Builder getDField() {
			return dField;
		}
		
		@Override
		public D22.D22Builder getOrCreateDField() {
			D22.D22Builder result;
			if (dField!=null) {
				result = dField;
			}
			else {
				result = dField = D22.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("cEnum")
		public C22.C22Builder setCEnum(TestEnum cEnum) {
			this.cEnum = cEnum==null?null:cEnum;
			return this;
		}
		@Override
		@RosettaAttribute("dField")
		public C22.C22Builder setDField(D22 dField) {
			this.dField = dField==null?null:dField.toBuilder();
			return this;
		}
		
		@Override
		public C22 build() {
			return new C22.C22Impl(this);
		}
		
		@Override
		public C22.C22Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public C22.C22Builder prune() {
			if (dField!=null && !dField.prune().hasData()) dField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getCEnum()!=null) return true;
			if (getDField()!=null && getDField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public C22.C22Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			C22.C22Builder o = (C22.C22Builder) other;
			
			merger.mergeRosetta(getDField(), o.getDField(), this::setDField);
			
			merger.mergeBasic(getCEnum(), o.getCEnum(), this::setCEnum);
			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;
		
			C22 _that = getType().cast(o);
		
			if (!Objects.equals(cEnum, _that.getCEnum())) return false;
			if (!Objects.equals(dField, _that.getDField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (cEnum != null ? cEnum.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (dField != null ? dField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "C22Builder {" +
				"cEnum=" + this.cEnum + ", " +
				"dField=" + this.dField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy