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

com.rosetta.testconditional.model.V5 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testconditional.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.testconditional.model.V5;
import com.rosetta.testconditional.model.V5.V5Builder;
import com.rosetta.testconditional.model.V5.V5BuilderImpl;
import com.rosetta.testconditional.model.V5.V5Impl;
import com.rosetta.testconditional.model.W5;
import com.rosetta.testconditional.model.meta.V5Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	V5Meta metaData = new V5Meta();

	/*********************** Getter Methods  ***********************/
	W5 getWField();
	String getXField();

	/*********************** Build Methods  ***********************/
	V5 build();
	
	V5.V5Builder toBuilder();
	
	static V5.V5Builder builder() {
		return new V5.V5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return V5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("wField"), processor, W5.class, getWField());
		processor.processBasic(path.newSubPath("xField"), String.class, getXField(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface V5Builder extends V5, RosettaModelObjectBuilder {
		W5.W5Builder getOrCreateWField();
		W5.W5Builder getWField();
		V5.V5Builder setWField(W5 wField);
		V5.V5Builder setXField(String xField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("wField"), processor, W5.W5Builder.class, getWField());
			processor.processBasic(path.newSubPath("xField"), String.class, getXField(), this);
		}
		

		V5.V5Builder prune();
	}

	/*********************** Immutable Implementation of V5  ***********************/
	class V5Impl implements V5 {
		private final W5 wField;
		private final String xField;
		
		protected V5Impl(V5.V5Builder builder) {
			this.wField = ofNullable(builder.getWField()).map(f->f.build()).orElse(null);
			this.xField = builder.getXField();
		}
		
		@Override
		@RosettaAttribute("wField")
		public W5 getWField() {
			return wField;
		}
		
		@Override
		@RosettaAttribute("xField")
		public String getXField() {
			return xField;
		}
		
		@Override
		public V5 build() {
			return this;
		}
		
		@Override
		public V5.V5Builder toBuilder() {
			V5.V5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(V5.V5Builder builder) {
			ofNullable(getWField()).ifPresent(builder::setWField);
			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;
		
			V5 _that = getType().cast(o);
		
			if (!Objects.equals(wField, _that.getWField())) return false;
			if (!Objects.equals(xField, _that.getXField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (wField != null ? wField.hashCode() : 0);
			_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "V5 {" +
				"wField=" + this.wField + ", " +
				"xField=" + this.xField +
			'}';
		}
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy