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

com.rosetta.testconditional.model.V11 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.V11;
import com.rosetta.testconditional.model.V11.V11Builder;
import com.rosetta.testconditional.model.V11.V11BuilderImpl;
import com.rosetta.testconditional.model.V11.V11Impl;
import com.rosetta.testconditional.model.W11;
import com.rosetta.testconditional.model.meta.V11Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	V11Meta metaData = new V11Meta();

	/*********************** Getter Methods  ***********************/
	W11 getWField1();
	W11 getWField2();

	/*********************** Build Methods  ***********************/
	V11 build();
	
	V11.V11Builder toBuilder();
	
	static V11.V11Builder builder() {
		return new V11.V11BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return V11.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("wField1"), processor, W11.class, getWField1());
		processRosetta(path.newSubPath("wField2"), processor, W11.class, getWField2());
	}
	

	/*********************** Builder Interface  ***********************/
	interface V11Builder extends V11, RosettaModelObjectBuilder {
		W11.W11Builder getOrCreateWField1();
		W11.W11Builder getWField1();
		W11.W11Builder getOrCreateWField2();
		W11.W11Builder getWField2();
		V11.V11Builder setWField1(W11 wField1);
		V11.V11Builder setWField2(W11 wField2);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("wField1"), processor, W11.W11Builder.class, getWField1());
			processRosetta(path.newSubPath("wField2"), processor, W11.W11Builder.class, getWField2());
		}
		

		V11.V11Builder prune();
	}

	/*********************** Immutable Implementation of V11  ***********************/
	class V11Impl implements V11 {
		private final W11 wField1;
		private final W11 wField2;
		
		protected V11Impl(V11.V11Builder builder) {
			this.wField1 = ofNullable(builder.getWField1()).map(f->f.build()).orElse(null);
			this.wField2 = ofNullable(builder.getWField2()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("wField1")
		public W11 getWField1() {
			return wField1;
		}
		
		@Override
		@RosettaAttribute("wField2")
		public W11 getWField2() {
			return wField2;
		}
		
		@Override
		public V11 build() {
			return this;
		}
		
		@Override
		public V11.V11Builder toBuilder() {
			V11.V11Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(V11.V11Builder builder) {
			ofNullable(getWField1()).ifPresent(builder::setWField1);
			ofNullable(getWField2()).ifPresent(builder::setWField2);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			V11 _that = getType().cast(o);
		
			if (!Objects.equals(wField1, _that.getWField1())) return false;
			if (!Objects.equals(wField2, _that.getWField2())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (wField1 != null ? wField1.hashCode() : 0);
			_result = 31 * _result + (wField2 != null ? wField2.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "V11 {" +
				"wField1=" + this.wField1 + ", " +
				"wField2=" + this.wField2 +
			'}';
		}
	}

	/*********************** Builder Implementation of V11  ***********************/
	class V11BuilderImpl implements V11.V11Builder {
	
		protected W11.W11Builder wField1;
		protected W11.W11Builder wField2;
	
		public V11BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("wField1")
		public W11.W11Builder getWField1() {
			return wField1;
		}
		
		@Override
		public W11.W11Builder getOrCreateWField1() {
			W11.W11Builder result;
			if (wField1!=null) {
				result = wField1;
			}
			else {
				result = wField1 = W11.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("wField2")
		public W11.W11Builder getWField2() {
			return wField2;
		}
		
		@Override
		public W11.W11Builder getOrCreateWField2() {
			W11.W11Builder result;
			if (wField2!=null) {
				result = wField2;
			}
			else {
				result = wField2 = W11.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("wField1")
		public V11.V11Builder setWField1(W11 wField1) {
			this.wField1 = wField1==null?null:wField1.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("wField2")
		public V11.V11Builder setWField2(W11 wField2) {
			this.wField2 = wField2==null?null:wField2.toBuilder();
			return this;
		}
		
		@Override
		public V11 build() {
			return new V11.V11Impl(this);
		}
		
		@Override
		public V11.V11Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public V11.V11Builder prune() {
			if (wField1!=null && !wField1.prune().hasData()) wField1 = null;
			if (wField2!=null && !wField2.prune().hasData()) wField2 = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getWField1()!=null && getWField1().hasData()) return true;
			if (getWField2()!=null && getWField2().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public V11.V11Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			V11.V11Builder o = (V11.V11Builder) other;
			
			merger.mergeRosetta(getWField1(), o.getWField1(), this::setWField1);
			merger.mergeRosetta(getWField2(), o.getWField2(), this::setWField2);
			
			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;
		
			V11 _that = getType().cast(o);
		
			if (!Objects.equals(wField1, _that.getWField1())) return false;
			if (!Objects.equals(wField2, _that.getWField2())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (wField1 != null ? wField1.hashCode() : 0);
			_result = 31 * _result + (wField2 != null ? wField2.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "V11Builder {" +
				"wField1=" + this.wField1 + ", " +
				"wField2=" + this.wField2 +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy