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

com.rosetta.testcard.model.W8_2 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testcard.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.testcard.model.W8_2;
import com.rosetta.testcard.model.W8_2.W8_2Builder;
import com.rosetta.testcard.model.W8_2.W8_2BuilderImpl;
import com.rosetta.testcard.model.W8_2.W8_2Impl;
import com.rosetta.testcard.model.Y8_2;
import com.rosetta.testcard.model.meta.W8_2Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	W8_2Meta metaData = new W8_2Meta();

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

	/*********************** Build Methods  ***********************/
	W8_2 build();
	
	W8_2.W8_2Builder toBuilder();
	
	static W8_2.W8_2Builder builder() {
		return new W8_2.W8_2BuilderImpl();
	}

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

	/*********************** Builder Interface  ***********************/
	interface W8_2Builder extends W8_2, RosettaModelObjectBuilder {
		Y8_2.Y8_2Builder getOrCreateYField();
		Y8_2.Y8_2Builder getYField();
		W8_2.W8_2Builder setYField(Y8_2 yField);

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

		W8_2.W8_2Builder prune();
	}

	/*********************** Immutable Implementation of W8_2  ***********************/
	class W8_2Impl implements W8_2 {
		private final Y8_2 yField;
		
		protected W8_2Impl(W8_2.W8_2Builder builder) {
			this.yField = ofNullable(builder.getYField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("yField")
		public Y8_2 getYField() {
			return yField;
		}
		
		@Override
		public W8_2 build() {
			return this;
		}
		
		@Override
		public W8_2.W8_2Builder toBuilder() {
			W8_2.W8_2Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(W8_2.W8_2Builder 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;
		
			W8_2 _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 "W8_2 {" +
				"yField=" + this.yField +
			'}';
		}
	}

	/*********************** Builder Implementation of W8_2  ***********************/
	class W8_2BuilderImpl implements W8_2.W8_2Builder {
	
		protected Y8_2.Y8_2Builder yField;
	
		public W8_2BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("yField")
		public Y8_2.Y8_2Builder getYField() {
			return yField;
		}
		
		@Override
		public Y8_2.Y8_2Builder getOrCreateYField() {
			Y8_2.Y8_2Builder result;
			if (yField!=null) {
				result = yField;
			}
			else {
				result = yField = Y8_2.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("yField")
		public W8_2.W8_2Builder setYField(Y8_2 yField) {
			this.yField = yField==null?null:yField.toBuilder();
			return this;
		}
		
		@Override
		public W8_2 build() {
			return new W8_2.W8_2Impl(this);
		}
		
		@Override
		public W8_2.W8_2Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W8_2.W8_2Builder 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 W8_2.W8_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			W8_2.W8_2Builder o = (W8_2.W8_2Builder) 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;
		
			W8_2 _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 "W8_2Builder {" +
				"yField=" + this.yField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy