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

com.rosetta.testconditional.model.W20_2 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.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
import com.rosetta.testconditional.model.W20_2;
import com.rosetta.testconditional.model.W20_2.W20_2Builder;
import com.rosetta.testconditional.model.W20_2.W20_2BuilderImpl;
import com.rosetta.testconditional.model.W20_2.W20_2Impl;
import com.rosetta.testconditional.model.meta.W20_2Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	W20_2Meta metaData = new W20_2Meta();

	/*********************** Getter Methods  ***********************/
	FieldWithMetaString getXField();

	/*********************** Build Methods  ***********************/
	W20_2 build();
	
	W20_2.W20_2Builder toBuilder();
	
	static W20_2.W20_2Builder builder() {
		return new W20_2.W20_2BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return W20_2.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.class, getXField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface W20_2Builder extends W20_2, RosettaModelObjectBuilder {
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateXField();
		FieldWithMetaString.FieldWithMetaStringBuilder getXField();
		W20_2.W20_2Builder setXField(FieldWithMetaString xField0);
		W20_2.W20_2Builder setXFieldValue(String xField1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("xField"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getXField());
		}
		

		W20_2.W20_2Builder prune();
	}

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

	/*********************** Builder Implementation of W20_2  ***********************/
	class W20_2BuilderImpl implements W20_2.W20_2Builder {
	
		protected FieldWithMetaString.FieldWithMetaStringBuilder xField;
	
		public W20_2BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("xField")
		public FieldWithMetaString.FieldWithMetaStringBuilder getXField() {
			return xField;
		}
		
		@Override
		public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreateXField() {
			FieldWithMetaString.FieldWithMetaStringBuilder result;
			if (xField!=null) {
				result = xField;
			}
			else {
				result = xField = FieldWithMetaString.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("xField")
		public W20_2.W20_2Builder setXField(FieldWithMetaString xField) {
			this.xField = xField==null?null:xField.toBuilder();
			return this;
		}
		@Override
		public W20_2.W20_2Builder setXFieldValue(String xField) {
			this.getOrCreateXField().setValue(xField);
			return this;
		}
		
		@Override
		public W20_2 build() {
			return new W20_2.W20_2Impl(this);
		}
		
		@Override
		public W20_2.W20_2Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W20_2.W20_2Builder prune() {
			if (xField!=null && !xField.prune().hasData()) xField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getXField()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W20_2.W20_2Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			W20_2.W20_2Builder o = (W20_2.W20_2Builder) other;
			
			merger.mergeRosetta(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;
		
			W20_2 _that = getType().cast(o);
		
			if (!Objects.equals(xField, _that.getXField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (xField != null ? xField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "W20_2Builder {" +
				"xField=" + this.xField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy