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

com.rosetta.testconditional.model.W4 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.W4;
import com.rosetta.testconditional.model.W4.W4Builder;
import com.rosetta.testconditional.model.W4.W4BuilderImpl;
import com.rosetta.testconditional.model.W4.W4Impl;
import com.rosetta.testconditional.model.Y4;
import com.rosetta.testconditional.model.meta.W4Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	W4Meta metaData = new W4Meta();

	/*********************** Getter Methods  ***********************/
	Y4 getYField();

	/*********************** Build Methods  ***********************/
	W4 build();
	
	W4.W4Builder toBuilder();
	
	static W4.W4Builder builder() {
		return new W4.W4BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface W4Builder extends W4, RosettaModelObjectBuilder {
		Y4.Y4Builder getOrCreateYField();
		Y4.Y4Builder getYField();
		W4.W4Builder setYField(Y4 yField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("yField"), processor, Y4.Y4Builder.class, getYField());
		}
		

		W4.W4Builder prune();
	}

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

	/*********************** Builder Implementation of W4  ***********************/
	class W4BuilderImpl implements W4.W4Builder {
	
		protected Y4.Y4Builder yField;
	
		public W4BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("yField")
		public Y4.Y4Builder getYField() {
			return yField;
		}
		
		@Override
		public Y4.Y4Builder getOrCreateYField() {
			Y4.Y4Builder result;
			if (yField!=null) {
				result = yField;
			}
			else {
				result = yField = Y4.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("yField")
		public W4.W4Builder setYField(Y4 yField) {
			this.yField = yField==null?null:yField.toBuilder();
			return this;
		}
		
		@Override
		public W4 build() {
			return new W4.W4Impl(this);
		}
		
		@Override
		public W4.W4Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W4.W4Builder prune() {
			if (yField!=null && !yField.prune().hasData()) yField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getYField()!=null && getYField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W4.W4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			W4.W4Builder o = (W4.W4Builder) other;
			
			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;
		
			W4 _that = getType().cast(o);
		
			if (!Objects.equals(yField, _that.getYField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (yField != null ? yField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "W4Builder {" +
				"yField=" + this.yField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy