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

com.rosetta.teststruct.model.B9 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.B9;
import com.rosetta.teststruct.model.B9.B9Builder;
import com.rosetta.teststruct.model.B9.B9BuilderImpl;
import com.rosetta.teststruct.model.B9.B9Impl;
import com.rosetta.teststruct.model.meta.B9Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	B9Meta metaData = new B9Meta();

	/*********************** Getter Methods  ***********************/
	String getCField();
	String getDField();

	/*********************** Build Methods  ***********************/
	B9 build();
	
	B9.B9Builder toBuilder();
	
	static B9.B9Builder builder() {
		return new B9.B9BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface B9Builder extends B9, RosettaModelObjectBuilder {
		B9.B9Builder setCField(String cField);
		B9.B9Builder setDField(String dField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("cField"), String.class, getCField(), this);
			processor.processBasic(path.newSubPath("dField"), String.class, getDField(), this);
		}
		

		B9.B9Builder prune();
	}

	/*********************** Immutable Implementation of B9  ***********************/
	class B9Impl implements B9 {
		private final String cField;
		private final String dField;
		
		protected B9Impl(B9.B9Builder builder) {
			this.cField = builder.getCField();
			this.dField = builder.getDField();
		}
		
		@Override
		@RosettaAttribute("cField")
		public String getCField() {
			return cField;
		}
		
		@Override
		@RosettaAttribute("dField")
		public String getDField() {
			return dField;
		}
		
		@Override
		public B9 build() {
			return this;
		}
		
		@Override
		public B9.B9Builder toBuilder() {
			B9.B9Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(B9.B9Builder builder) {
			ofNullable(getCField()).ifPresent(builder::setCField);
			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;
		
			B9 _that = getType().cast(o);
		
			if (!Objects.equals(cField, _that.getCField())) return false;
			if (!Objects.equals(dField, _that.getDField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
			_result = 31 * _result + (dField != null ? dField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "B9 {" +
				"cField=" + this.cField + ", " +
				"dField=" + this.dField +
			'}';
		}
	}

	/*********************** Builder Implementation of B9  ***********************/
	class B9BuilderImpl implements B9.B9Builder {
	
		protected String cField;
		protected String dField;
	
		public B9BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("cField")
		public String getCField() {
			return cField;
		}
		
		@Override
		@RosettaAttribute("dField")
		public String getDField() {
			return dField;
		}
		
		@Override
		@RosettaAttribute("cField")
		public B9.B9Builder setCField(String cField) {
			this.cField = cField==null?null:cField;
			return this;
		}
		@Override
		@RosettaAttribute("dField")
		public B9.B9Builder setDField(String dField) {
			this.dField = dField==null?null:dField;
			return this;
		}
		
		@Override
		public B9 build() {
			return new B9.B9Impl(this);
		}
		
		@Override
		public B9.B9Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B9.B9Builder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getCField()!=null) return true;
			if (getDField()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B9.B9Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			B9.B9Builder o = (B9.B9Builder) other;
			
			
			merger.mergeBasic(getCField(), o.getCField(), this::setCField);
			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;
		
			B9 _that = getType().cast(o);
		
			if (!Objects.equals(cField, _that.getCField())) return false;
			if (!Objects.equals(dField, _that.getDField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
			_result = 31 * _result + (dField != null ? dField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "B9Builder {" +
				"cField=" + this.cField + ", " +
				"dField=" + this.dField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy