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

com.rosetta.testconditional.model.A22 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.A22;
import com.rosetta.testconditional.model.A22.A22Builder;
import com.rosetta.testconditional.model.A22.A22BuilderImpl;
import com.rosetta.testconditional.model.A22.A22Impl;
import com.rosetta.testconditional.model.B22;
import com.rosetta.testconditional.model.meta.A22Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	A22Meta metaData = new A22Meta();

	/*********************** Getter Methods  ***********************/
	B22 getBField();

	/*********************** Build Methods  ***********************/
	A22 build();
	
	A22.A22Builder toBuilder();
	
	static A22.A22Builder builder() {
		return new A22.A22BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface A22Builder extends A22, RosettaModelObjectBuilder {
		B22.B22Builder getOrCreateBField();
		B22.B22Builder getBField();
		A22.A22Builder setBField(B22 bField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("bField"), processor, B22.B22Builder.class, getBField());
		}
		

		A22.A22Builder prune();
	}

	/*********************** Immutable Implementation of A22  ***********************/
	class A22Impl implements A22 {
		private final B22 bField;
		
		protected A22Impl(A22.A22Builder builder) {
			this.bField = ofNullable(builder.getBField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("bField")
		public B22 getBField() {
			return bField;
		}
		
		@Override
		public A22 build() {
			return this;
		}
		
		@Override
		public A22.A22Builder toBuilder() {
			A22.A22Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(A22.A22Builder builder) {
			ofNullable(getBField()).ifPresent(builder::setBField);
		}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy