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

com.rosetta.testconditional.model.W20_1 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_1;
import com.rosetta.testconditional.model.W20_1.W20_1Builder;
import com.rosetta.testconditional.model.W20_1.W20_1BuilderImpl;
import com.rosetta.testconditional.model.W20_1.W20_1Impl;
import com.rosetta.testconditional.model.meta.W20_1Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	W20_1Meta metaData = new W20_1Meta();

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

	/*********************** Build Methods  ***********************/
	W20_1 build();
	
	W20_1.W20_1Builder toBuilder();
	
	static W20_1.W20_1Builder builder() {
		return new W20_1.W20_1BuilderImpl();
	}

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

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

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

		W20_1.W20_1Builder prune();
	}

	/*********************** Immutable Implementation of W20_1  ***********************/
	class W20_1Impl implements W20_1 {
		private final FieldWithMetaString xField;
		
		protected W20_1Impl(W20_1.W20_1Builder builder) {
			this.xField = ofNullable(builder.getXField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("xField")
		public FieldWithMetaString getXField() {
			return xField;
		}
		
		@Override
		public W20_1 build() {
			return this;
		}
		
		@Override
		public W20_1.W20_1Builder toBuilder() {
			W20_1.W20_1Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(W20_1.W20_1Builder 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_1 _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_1 {" +
				"xField=" + this.xField +
			'}';
		}
	}

	/*********************** Builder Implementation of W20_1  ***********************/
	class W20_1BuilderImpl implements W20_1.W20_1Builder {
	
		protected FieldWithMetaString.FieldWithMetaStringBuilder xField;
	
		public W20_1BuilderImpl() {
		}
	
		@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_1.W20_1Builder setXField(FieldWithMetaString xField) {
			this.xField = xField==null?null:xField.toBuilder();
			return this;
		}
		@Override
		public W20_1.W20_1Builder setXFieldValue(String xField) {
			this.getOrCreateXField().setValue(xField);
			return this;
		}
		
		@Override
		public W20_1 build() {
			return new W20_1.W20_1Impl(this);
		}
		
		@Override
		public W20_1.W20_1Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public W20_1.W20_1Builder 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_1.W20_1Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			W20_1.W20_1Builder o = (W20_1.W20_1Builder) 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_1 _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_1Builder {" +
				"xField=" + this.xField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy