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

com.rosetta.externalsynonym.model.Top8 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.externalsynonym.model;

import com.rosetta.externalsynonym.model.Top8;
import com.rosetta.externalsynonym.model.Top8.Top8Builder;
import com.rosetta.externalsynonym.model.Top8.Top8BuilderImpl;
import com.rosetta.externalsynonym.model.Top8.Top8Impl;
import com.rosetta.externalsynonym.model.X8;
import com.rosetta.externalsynonym.model.Y8;
import com.rosetta.externalsynonym.model.meta.Top8Meta;
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 java.util.Objects;

import static java.util.Optional.ofNullable;

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

	Top8Meta metaData = new Top8Meta();

	/*********************** Getter Methods  ***********************/
	X8 getXField();
	Y8 getYField();

	/*********************** Build Methods  ***********************/
	Top8 build();
	
	Top8.Top8Builder toBuilder();
	
	static Top8.Top8Builder builder() {
		return new Top8.Top8BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface Top8Builder extends Top8, RosettaModelObjectBuilder {
		X8.X8Builder getOrCreateXField();
		X8.X8Builder getXField();
		Y8.Y8Builder getOrCreateYField();
		Y8.Y8Builder getYField();
		Top8.Top8Builder setXField(X8 xField);
		Top8.Top8Builder setYField(Y8 yField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("xField"), processor, X8.X8Builder.class, getXField());
			processRosetta(path.newSubPath("yField"), processor, Y8.Y8Builder.class, getYField());
		}
		

		Top8.Top8Builder prune();
	}

	/*********************** Immutable Implementation of Top8  ***********************/
	class Top8Impl implements Top8 {
		private final X8 xField;
		private final Y8 yField;
		
		protected Top8Impl(Top8.Top8Builder builder) {
			this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
			this.yField = ofNullable(builder.getYField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("xField")
		public X8 getXField() {
			return xField;
		}
		
		@Override
		@RosettaAttribute("yField")
		public Y8 getYField() {
			return yField;
		}
		
		@Override
		public Top8 build() {
			return this;
		}
		
		@Override
		public Top8.Top8Builder toBuilder() {
			Top8.Top8Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Top8.Top8Builder builder) {
			ofNullable(getXField()).ifPresent(builder::setXField);
			ofNullable(getYField()).ifPresent(builder::setYField);
		}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy