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

com.rosetta.testconditional.model.B22 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.B22;
import com.rosetta.testconditional.model.B22.B22Builder;
import com.rosetta.testconditional.model.B22.B22BuilderImpl;
import com.rosetta.testconditional.model.B22.B22Impl;
import com.rosetta.testconditional.model.C22;
import com.rosetta.testconditional.model.meta.B22Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	B22Meta metaData = new B22Meta();

	/*********************** Getter Methods  ***********************/
	C22 getCField();

	/*********************** Build Methods  ***********************/
	B22 build();
	
	B22.B22Builder toBuilder();
	
	static B22.B22Builder builder() {
		return new B22.B22BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return B22.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("cField"), processor, C22.class, getCField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface B22Builder extends B22, RosettaModelObjectBuilder {
		C22.C22Builder getOrCreateCField();
		C22.C22Builder getCField();
		B22.B22Builder setCField(C22 cField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("cField"), processor, C22.C22Builder.class, getCField());
		}
		

		B22.B22Builder prune();
	}

	/*********************** Immutable Implementation of B22  ***********************/
	class B22Impl implements B22 {
		private final C22 cField;
		
		protected B22Impl(B22.B22Builder builder) {
			this.cField = ofNullable(builder.getCField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("cField")
		public C22 getCField() {
			return cField;
		}
		
		@Override
		public B22 build() {
			return this;
		}
		
		@Override
		public B22.B22Builder toBuilder() {
			B22.B22Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(B22.B22Builder builder) {
			ofNullable(getCField()).ifPresent(builder::setCField);
		}

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

	/*********************** Builder Implementation of B22  ***********************/
	class B22BuilderImpl implements B22.B22Builder {
	
		protected C22.C22Builder cField;
	
		public B22BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("cField")
		public C22.C22Builder getCField() {
			return cField;
		}
		
		@Override
		public C22.C22Builder getOrCreateCField() {
			C22.C22Builder result;
			if (cField!=null) {
				result = cField;
			}
			else {
				result = cField = C22.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("cField")
		public B22.B22Builder setCField(C22 cField) {
			this.cField = cField==null?null:cField.toBuilder();
			return this;
		}
		
		@Override
		public B22 build() {
			return new B22.B22Impl(this);
		}
		
		@Override
		public B22.B22Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B22.B22Builder prune() {
			if (cField!=null && !cField.prune().hasData()) cField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getCField()!=null && getCField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B22.B22Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			B22.B22Builder o = (B22.B22Builder) other;
			
			merger.mergeRosetta(getCField(), o.getCField(), this::setCField);
			
			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;
		
			B22 _that = getType().cast(o);
		
			if (!Objects.equals(cField, _that.getCField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "B22Builder {" +
				"cField=" + this.cField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy