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

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

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

import com.rosetta.externalsynonym.model.X5;
import com.rosetta.externalsynonym.model.X5.X5Builder;
import com.rosetta.externalsynonym.model.X5.X5BuilderImpl;
import com.rosetta.externalsynonym.model.X5.X5Impl;
import com.rosetta.externalsynonym.model.Y5;
import com.rosetta.externalsynonym.model.meta.X5Meta;
import com.rosetta.externalsynonym.model.metafields.ReferenceWithMetaY5;
import com.rosetta.externalsynonym.model.metafields.ReferenceWithMetaY5.ReferenceWithMetaY5Builder;
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="X5", builder=X5.X5BuilderImpl.class, version="test")
public interface X5 extends RosettaModelObject {

	X5Meta metaData = new X5Meta();

	/*********************** Getter Methods  ***********************/
	ReferenceWithMetaY5 getYReference();
	Y5 getYField();

	/*********************** Build Methods  ***********************/
	X5 build();
	
	X5.X5Builder toBuilder();
	
	static X5.X5Builder builder() {
		return new X5.X5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return X5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("yReference"), processor, ReferenceWithMetaY5.class, getYReference());
		processRosetta(path.newSubPath("yField"), processor, Y5.class, getYField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface X5Builder extends X5, RosettaModelObjectBuilder {
		ReferenceWithMetaY5.ReferenceWithMetaY5Builder getOrCreateYReference();
		ReferenceWithMetaY5.ReferenceWithMetaY5Builder getYReference();
		Y5.Y5Builder getOrCreateYField();
		Y5.Y5Builder getYField();
		X5.X5Builder setYReference(ReferenceWithMetaY5 yReference0);
		X5.X5Builder setYReferenceValue(Y5 yReference1);
		X5.X5Builder setYField(Y5 yField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("yReference"), processor, ReferenceWithMetaY5.ReferenceWithMetaY5Builder.class, getYReference());
			processRosetta(path.newSubPath("yField"), processor, Y5.Y5Builder.class, getYField());
		}
		

		X5.X5Builder prune();
	}

	/*********************** Immutable Implementation of X5  ***********************/
	class X5Impl implements X5 {
		private final ReferenceWithMetaY5 yReference;
		private final Y5 yField;
		
		protected X5Impl(X5.X5Builder builder) {
			this.yReference = ofNullable(builder.getYReference()).map(f->f.build()).orElse(null);
			this.yField = ofNullable(builder.getYField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("yReference")
		public ReferenceWithMetaY5 getYReference() {
			return yReference;
		}
		
		@Override
		@RosettaAttribute("yField")
		public Y5 getYField() {
			return yField;
		}
		
		@Override
		public X5 build() {
			return this;
		}
		
		@Override
		public X5.X5Builder toBuilder() {
			X5.X5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(X5.X5Builder builder) {
			ofNullable(getYReference()).ifPresent(builder::setYReference);
			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;
		
			X5 _that = getType().cast(o);
		
			if (!Objects.equals(yReference, _that.getYReference())) return false;
			if (!Objects.equals(yField, _that.getYField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (yReference != null ? yReference.hashCode() : 0);
			_result = 31 * _result + (yField != null ? yField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "X5 {" +
				"yReference=" + this.yReference + ", " +
				"yField=" + this.yField +
			'}';
		}
	}

	/*********************** Builder Implementation of X5  ***********************/
	class X5BuilderImpl implements X5.X5Builder {
	
		protected ReferenceWithMetaY5.ReferenceWithMetaY5Builder yReference;
		protected Y5.Y5Builder yField;
	
		public X5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("yReference")
		public ReferenceWithMetaY5.ReferenceWithMetaY5Builder getYReference() {
			return yReference;
		}
		
		@Override
		public ReferenceWithMetaY5.ReferenceWithMetaY5Builder getOrCreateYReference() {
			ReferenceWithMetaY5.ReferenceWithMetaY5Builder result;
			if (yReference!=null) {
				result = yReference;
			}
			else {
				result = yReference = ReferenceWithMetaY5.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("yField")
		public Y5.Y5Builder getYField() {
			return yField;
		}
		
		@Override
		public Y5.Y5Builder getOrCreateYField() {
			Y5.Y5Builder result;
			if (yField!=null) {
				result = yField;
			}
			else {
				result = yField = Y5.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("yReference")
		public X5.X5Builder setYReference(ReferenceWithMetaY5 yReference) {
			this.yReference = yReference==null?null:yReference.toBuilder();
			return this;
		}
		@Override
		public X5.X5Builder setYReferenceValue(Y5 yReference) {
			this.getOrCreateYReference().setValue(yReference);
			return this;
		}
		@Override
		@RosettaAttribute("yField")
		public X5.X5Builder setYField(Y5 yField) {
			this.yField = yField==null?null:yField.toBuilder();
			return this;
		}
		
		@Override
		public X5 build() {
			return new X5.X5Impl(this);
		}
		
		@Override
		public X5.X5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public X5.X5Builder prune() {
			if (yReference!=null && !yReference.prune().hasData()) yReference = null;
			if (yField!=null && !yField.prune().hasData()) yField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getYReference()!=null && getYReference().hasData()) return true;
			if (getYField()!=null && getYField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public X5.X5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			X5.X5Builder o = (X5.X5Builder) other;
			
			merger.mergeRosetta(getYReference(), o.getYReference(), this::setYReference);
			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;
		
			X5 _that = getType().cast(o);
		
			if (!Objects.equals(yReference, _that.getYReference())) return false;
			if (!Objects.equals(yField, _that.getYField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (yReference != null ? yReference.hashCode() : 0);
			_result = 31 * _result + (yField != null ? yField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "X5Builder {" +
				"yReference=" + this.yReference + ", " +
				"yField=" + this.yField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy