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

com.rosetta.testcard.model.A5 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testcard.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.testcard.model.A5;
import com.rosetta.testcard.model.A5.A5Builder;
import com.rosetta.testcard.model.A5.A5BuilderImpl;
import com.rosetta.testcard.model.A5.A5Impl;
import com.rosetta.testcard.model.X5;
import com.rosetta.testcard.model.meta.A5Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	A5Meta metaData = new A5Meta();

	/*********************** Getter Methods  ***********************/
	X5 getXField();

	/*********************** Build Methods  ***********************/
	A5 build();
	
	A5.A5Builder toBuilder();
	
	static A5.A5Builder builder() {
		return new A5.A5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return A5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("xField"), processor, X5.class, getXField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface A5Builder extends A5, RosettaModelObjectBuilder {
		X5.X5Builder getOrCreateXField();
		X5.X5Builder getXField();
		A5.A5Builder setXField(X5 xField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("xField"), processor, X5.X5Builder.class, getXField());
		}
		

		A5.A5Builder prune();
	}

	/*********************** Immutable Implementation of A5  ***********************/
	class A5Impl implements A5 {
		private final X5 xField;
		
		protected A5Impl(A5.A5Builder builder) {
			this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("xField")
		public X5 getXField() {
			return xField;
		}
		
		@Override
		public A5 build() {
			return this;
		}
		
		@Override
		public A5.A5Builder toBuilder() {
			A5.A5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(A5.A5Builder builder) {
			ofNullable(getXField()).ifPresent(builder::setXField);
		}

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

	/*********************** Builder Implementation of A5  ***********************/
	class A5BuilderImpl implements A5.A5Builder {
	
		protected X5.X5Builder xField;
	
		public A5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("xField")
		public X5.X5Builder getXField() {
			return xField;
		}
		
		@Override
		public X5.X5Builder getOrCreateXField() {
			X5.X5Builder result;
			if (xField!=null) {
				result = xField;
			}
			else {
				result = xField = X5.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("xField")
		public A5.A5Builder setXField(X5 xField) {
			this.xField = xField==null?null:xField.toBuilder();
			return this;
		}
		
		@Override
		public A5 build() {
			return new A5.A5Impl(this);
		}
		
		@Override
		public A5.A5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A5.A5Builder prune() {
			if (xField!=null && !xField.prune().hasData()) xField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getXField()!=null && getXField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A5.A5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			A5.A5Builder o = (A5.A5Builder) other;
			
			merger.mergeRosetta(getXField(), o.getXField(), this::setXField);
			
			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;
		
			A5 _that = getType().cast(o);
		
			if (!Objects.equals(xField, _that.getXField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "A5Builder {" +
				"xField=" + this.xField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy