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

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

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

import com.rosetta.externalsynonym.model.Y5;
import com.rosetta.externalsynonym.model.Y5.Y5Builder;
import com.rosetta.externalsynonym.model.Y5.Y5BuilderImpl;
import com.rosetta.externalsynonym.model.Y5.Y5Impl;
import com.rosetta.externalsynonym.model.ZEnum5;
import com.rosetta.externalsynonym.model.meta.Y5Meta;
import com.rosetta.model.lib.GlobalKey;
import com.rosetta.model.lib.GlobalKey.GlobalKeyBuilder;
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.model.metafields.MetaFields;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	Y5Meta metaData = new Y5Meta();

	/*********************** Getter Methods  ***********************/
	String getName();
	ZEnum5 getZField();
	String getZ2Field();
	MetaFields getMeta();

	/*********************** Build Methods  ***********************/
	Y5 build();
	
	Y5.Y5Builder toBuilder();
	
	static Y5.Y5Builder builder() {
		return new Y5.Y5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Y5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("name"), String.class, getName(), this);
		processor.processBasic(path.newSubPath("zField"), ZEnum5.class, getZField(), this);
		processor.processBasic(path.newSubPath("z2Field"), String.class, getZ2Field(), this);
		processRosetta(path.newSubPath("meta"), processor, MetaFields.class, getMeta());
	}
	

	/*********************** Builder Interface  ***********************/
	interface Y5Builder extends Y5, RosettaModelObjectBuilder {
		MetaFields.MetaFieldsBuilder getOrCreateMeta();
		MetaFields.MetaFieldsBuilder getMeta();
		Y5.Y5Builder setName(String name);
		Y5.Y5Builder setZField(ZEnum5 zField);
		Y5.Y5Builder setZ2Field(String z2Field);
		Y5.Y5Builder setMeta(MetaFields meta);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("name"), String.class, getName(), this);
			processor.processBasic(path.newSubPath("zField"), ZEnum5.class, getZField(), this);
			processor.processBasic(path.newSubPath("z2Field"), String.class, getZ2Field(), this);
			processRosetta(path.newSubPath("meta"), processor, MetaFields.MetaFieldsBuilder.class, getMeta());
		}
		

		Y5.Y5Builder prune();
	}

	/*********************** Immutable Implementation of Y5  ***********************/
	class Y5Impl implements Y5 {
		private final String name;
		private final ZEnum5 zField;
		private final String z2Field;
		private final MetaFields meta;
		
		protected Y5Impl(Y5.Y5Builder builder) {
			this.name = builder.getName();
			this.zField = builder.getZField();
			this.z2Field = builder.getZ2Field();
			this.meta = ofNullable(builder.getMeta()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("name")
		public String getName() {
			return name;
		}
		
		@Override
		@RosettaAttribute("zField")
		public ZEnum5 getZField() {
			return zField;
		}
		
		@Override
		@RosettaAttribute("z2Field")
		public String getZ2Field() {
			return z2Field;
		}
		
		@Override
		@RosettaAttribute("meta")
		public MetaFields getMeta() {
			return meta;
		}
		
		@Override
		public Y5 build() {
			return this;
		}
		
		@Override
		public Y5.Y5Builder toBuilder() {
			Y5.Y5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Y5.Y5Builder builder) {
			ofNullable(getName()).ifPresent(builder::setName);
			ofNullable(getZField()).ifPresent(builder::setZField);
			ofNullable(getZ2Field()).ifPresent(builder::setZ2Field);
			ofNullable(getMeta()).ifPresent(builder::setMeta);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			Y5 _that = getType().cast(o);
		
			if (!Objects.equals(name, _that.getName())) return false;
			if (!Objects.equals(zField, _that.getZField())) return false;
			if (!Objects.equals(z2Field, _that.getZ2Field())) return false;
			if (!Objects.equals(meta, _that.getMeta())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (name != null ? name.hashCode() : 0);
			_result = 31 * _result + (zField != null ? zField.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (z2Field != null ? z2Field.hashCode() : 0);
			_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Y5 {" +
				"name=" + this.name + ", " +
				"zField=" + this.zField + ", " +
				"z2Field=" + this.z2Field + ", " +
				"meta=" + this.meta +
			'}';
		}
	}

	/*********************** Builder Implementation of Y5  ***********************/
	class Y5BuilderImpl implements Y5.Y5Builder, GlobalKeyBuilder {
	
		protected String name;
		protected ZEnum5 zField;
		protected String z2Field;
		protected MetaFields.MetaFieldsBuilder meta;
	
		public Y5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("name")
		public String getName() {
			return name;
		}
		
		@Override
		@RosettaAttribute("zField")
		public ZEnum5 getZField() {
			return zField;
		}
		
		@Override
		@RosettaAttribute("z2Field")
		public String getZ2Field() {
			return z2Field;
		}
		
		@Override
		@RosettaAttribute("meta")
		public MetaFields.MetaFieldsBuilder getMeta() {
			return meta;
		}
		
		@Override
		public MetaFields.MetaFieldsBuilder getOrCreateMeta() {
			MetaFields.MetaFieldsBuilder result;
			if (meta!=null) {
				result = meta;
			}
			else {
				result = meta = MetaFields.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("name")
		public Y5.Y5Builder setName(String name) {
			this.name = name==null?null:name;
			return this;
		}
		@Override
		@RosettaAttribute("zField")
		public Y5.Y5Builder setZField(ZEnum5 zField) {
			this.zField = zField==null?null:zField;
			return this;
		}
		@Override
		@RosettaAttribute("z2Field")
		public Y5.Y5Builder setZ2Field(String z2Field) {
			this.z2Field = z2Field==null?null:z2Field;
			return this;
		}
		@Override
		@RosettaAttribute("meta")
		public Y5.Y5Builder setMeta(MetaFields meta) {
			this.meta = meta==null?null:meta.toBuilder();
			return this;
		}
		
		@Override
		public Y5 build() {
			return new Y5.Y5Impl(this);
		}
		
		@Override
		public Y5.Y5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Y5.Y5Builder prune() {
			if (meta!=null && !meta.prune().hasData()) meta = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getName()!=null) return true;
			if (getZField()!=null) return true;
			if (getZ2Field()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Y5.Y5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Y5.Y5Builder o = (Y5.Y5Builder) other;
			
			merger.mergeRosetta(getMeta(), o.getMeta(), this::setMeta);
			
			merger.mergeBasic(getName(), o.getName(), this::setName);
			merger.mergeBasic(getZField(), o.getZField(), this::setZField);
			merger.mergeBasic(getZ2Field(), o.getZ2Field(), this::setZ2Field);
			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;
		
			Y5 _that = getType().cast(o);
		
			if (!Objects.equals(name, _that.getName())) return false;
			if (!Objects.equals(zField, _that.getZField())) return false;
			if (!Objects.equals(z2Field, _that.getZ2Field())) return false;
			if (!Objects.equals(meta, _that.getMeta())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (name != null ? name.hashCode() : 0);
			_result = 31 * _result + (zField != null ? zField.getClass().getName().hashCode() : 0);
			_result = 31 * _result + (z2Field != null ? z2Field.hashCode() : 0);
			_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Y5Builder {" +
				"name=" + this.name + ", " +
				"zField=" + this.zField + ", " +
				"z2Field=" + this.z2Field + ", " +
				"meta=" + this.meta +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy