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

com.rosetta.test.conditionfunc.model.Z4 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.test.conditionfunc.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.test.conditionfunc.model.Z4;
import com.rosetta.test.conditionfunc.model.Z4.Z4Builder;
import com.rosetta.test.conditionfunc.model.Z4.Z4BuilderImpl;
import com.rosetta.test.conditionfunc.model.Z4.Z4Impl;
import com.rosetta.test.conditionfunc.model.meta.Z4Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	Z4Meta metaData = new Z4Meta();

	/*********************** Getter Methods  ***********************/
	String getStr1Field();
	String getStr2Field();

	/*********************** Build Methods  ***********************/
	Z4 build();
	
	Z4.Z4Builder toBuilder();
	
	static Z4.Z4Builder builder() {
		return new Z4.Z4BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Z4.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("str1Field"), String.class, getStr1Field(), this);
		processor.processBasic(path.newSubPath("str2Field"), String.class, getStr2Field(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface Z4Builder extends Z4, RosettaModelObjectBuilder {
		Z4.Z4Builder setStr1Field(String str1Field);
		Z4.Z4Builder setStr2Field(String str2Field);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("str1Field"), String.class, getStr1Field(), this);
			processor.processBasic(path.newSubPath("str2Field"), String.class, getStr2Field(), this);
		}
		

		Z4.Z4Builder prune();
	}

	/*********************** Immutable Implementation of Z4  ***********************/
	class Z4Impl implements Z4 {
		private final String str1Field;
		private final String str2Field;
		
		protected Z4Impl(Z4.Z4Builder builder) {
			this.str1Field = builder.getStr1Field();
			this.str2Field = builder.getStr2Field();
		}
		
		@Override
		@RosettaAttribute("str1Field")
		public String getStr1Field() {
			return str1Field;
		}
		
		@Override
		@RosettaAttribute("str2Field")
		public String getStr2Field() {
			return str2Field;
		}
		
		@Override
		public Z4 build() {
			return this;
		}
		
		@Override
		public Z4.Z4Builder toBuilder() {
			Z4.Z4Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Z4.Z4Builder builder) {
			ofNullable(getStr1Field()).ifPresent(builder::setStr1Field);
			ofNullable(getStr2Field()).ifPresent(builder::setStr2Field);
		}

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

	/*********************** Builder Implementation of Z4  ***********************/
	class Z4BuilderImpl implements Z4.Z4Builder {
	
		protected String str1Field;
		protected String str2Field;
	
		public Z4BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("str1Field")
		public String getStr1Field() {
			return str1Field;
		}
		
		@Override
		@RosettaAttribute("str2Field")
		public String getStr2Field() {
			return str2Field;
		}
		
		@Override
		@RosettaAttribute("str1Field")
		public Z4.Z4Builder setStr1Field(String str1Field) {
			this.str1Field = str1Field==null?null:str1Field;
			return this;
		}
		@Override
		@RosettaAttribute("str2Field")
		public Z4.Z4Builder setStr2Field(String str2Field) {
			this.str2Field = str2Field==null?null:str2Field;
			return this;
		}
		
		@Override
		public Z4 build() {
			return new Z4.Z4Impl(this);
		}
		
		@Override
		public Z4.Z4Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Z4.Z4Builder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getStr1Field()!=null) return true;
			if (getStr2Field()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Z4.Z4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Z4.Z4Builder o = (Z4.Z4Builder) other;
			
			
			merger.mergeBasic(getStr1Field(), o.getStr1Field(), this::setStr1Field);
			merger.mergeBasic(getStr2Field(), o.getStr2Field(), this::setStr2Field);
			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;
		
			Z4 _that = getType().cast(o);
		
			if (!Objects.equals(str1Field, _that.getStr1Field())) return false;
			if (!Objects.equals(str2Field, _that.getStr2Field())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (str1Field != null ? str1Field.hashCode() : 0);
			_result = 31 * _result + (str2Field != null ? str2Field.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "Z4Builder {" +
				"str1Field=" + this.str1Field + ", " +
				"str2Field=" + this.str2Field +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy