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

com.rosetta.teststruct.model.C5 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.teststruct.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.teststruct.model.C5;
import com.rosetta.teststruct.model.C5.C5Builder;
import com.rosetta.teststruct.model.C5.C5BuilderImpl;
import com.rosetta.teststruct.model.C5.C5Impl;
import com.rosetta.teststruct.model.meta.C5Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	C5Meta metaData = new C5Meta();

	/*********************** Getter Methods  ***********************/
	String getEField();
	String getFField();

	/*********************** Build Methods  ***********************/
	C5 build();
	
	C5.C5Builder toBuilder();
	
	static C5.C5Builder builder() {
		return new C5.C5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return C5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("eField"), String.class, getEField(), this);
		processor.processBasic(path.newSubPath("fField"), String.class, getFField(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface C5Builder extends C5, RosettaModelObjectBuilder {
		C5.C5Builder setEField(String eField);
		C5.C5Builder setFField(String fField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("eField"), String.class, getEField(), this);
			processor.processBasic(path.newSubPath("fField"), String.class, getFField(), this);
		}
		

		C5.C5Builder prune();
	}

	/*********************** Immutable Implementation of C5  ***********************/
	class C5Impl implements C5 {
		private final String eField;
		private final String fField;
		
		protected C5Impl(C5.C5Builder builder) {
			this.eField = builder.getEField();
			this.fField = builder.getFField();
		}
		
		@Override
		@RosettaAttribute("eField")
		public String getEField() {
			return eField;
		}
		
		@Override
		@RosettaAttribute("fField")
		public String getFField() {
			return fField;
		}
		
		@Override
		public C5 build() {
			return this;
		}
		
		@Override
		public C5.C5Builder toBuilder() {
			C5.C5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(C5.C5Builder builder) {
			ofNullable(getEField()).ifPresent(builder::setEField);
			ofNullable(getFField()).ifPresent(builder::setFField);
		}

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

	/*********************** Builder Implementation of C5  ***********************/
	class C5BuilderImpl implements C5.C5Builder {
	
		protected String eField;
		protected String fField;
	
		public C5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("eField")
		public String getEField() {
			return eField;
		}
		
		@Override
		@RosettaAttribute("fField")
		public String getFField() {
			return fField;
		}
		
		@Override
		@RosettaAttribute("eField")
		public C5.C5Builder setEField(String eField) {
			this.eField = eField==null?null:eField;
			return this;
		}
		@Override
		@RosettaAttribute("fField")
		public C5.C5Builder setFField(String fField) {
			this.fField = fField==null?null:fField;
			return this;
		}
		
		@Override
		public C5 build() {
			return new C5.C5Impl(this);
		}
		
		@Override
		public C5.C5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public C5.C5Builder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getEField()!=null) return true;
			if (getFField()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public C5.C5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			C5.C5Builder o = (C5.C5Builder) other;
			
			
			merger.mergeBasic(getEField(), o.getEField(), this::setEField);
			merger.mergeBasic(getFField(), o.getFField(), this::setFField);
			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;
		
			C5 _that = getType().cast(o);
		
			if (!Objects.equals(eField, _that.getEField())) return false;
			if (!Objects.equals(fField, _that.getFField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (eField != null ? eField.hashCode() : 0);
			_result = 31 * _result + (fField != null ? fField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "C5Builder {" +
				"eField=" + this.eField + ", " +
				"fField=" + this.fField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy