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

com.rosetta.teststruct.model.B5 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.B5;
import com.rosetta.teststruct.model.B5.B5Builder;
import com.rosetta.teststruct.model.B5.B5BuilderImpl;
import com.rosetta.teststruct.model.B5.B5Impl;
import com.rosetta.teststruct.model.C5;
import com.rosetta.teststruct.model.meta.B5Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	B5Meta metaData = new B5Meta();

	/*********************** Getter Methods  ***********************/
	C5 getCField();

	/*********************** Build Methods  ***********************/
	B5 build();
	
	B5.B5Builder toBuilder();
	
	static B5.B5Builder builder() {
		return new B5.B5BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return B5.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("cField"), processor, C5.class, getCField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface B5Builder extends B5, RosettaModelObjectBuilder {
		C5.C5Builder getOrCreateCField();
		C5.C5Builder getCField();
		B5.B5Builder setCField(C5 cField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("cField"), processor, C5.C5Builder.class, getCField());
		}
		

		B5.B5Builder prune();
	}

	/*********************** Immutable Implementation of B5  ***********************/
	class B5Impl implements B5 {
		private final C5 cField;
		
		protected B5Impl(B5.B5Builder builder) {
			this.cField = ofNullable(builder.getCField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("cField")
		public C5 getCField() {
			return cField;
		}
		
		@Override
		public B5 build() {
			return this;
		}
		
		@Override
		public B5.B5Builder toBuilder() {
			B5.B5Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(B5.B5Builder builder) {
			ofNullable(getCField()).ifPresent(builder::setCField);
		}

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

	/*********************** Builder Implementation of B5  ***********************/
	class B5BuilderImpl implements B5.B5Builder {
	
		protected C5.C5Builder cField;
	
		public B5BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("cField")
		public C5.C5Builder getCField() {
			return cField;
		}
		
		@Override
		public C5.C5Builder getOrCreateCField() {
			C5.C5Builder result;
			if (cField!=null) {
				result = cField;
			}
			else {
				result = cField = C5.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("cField")
		public B5.B5Builder setCField(C5 cField) {
			this.cField = cField==null?null:cField.toBuilder();
			return this;
		}
		
		@Override
		public B5 build() {
			return new B5.B5Impl(this);
		}
		
		@Override
		public B5.B5Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B5.B5Builder prune() {
			if (cField!=null && !cField.prune().hasData()) cField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getCField()!=null && getCField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public B5.B5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			B5.B5Builder o = (B5.B5Builder) other;
			
			merger.mergeRosetta(getCField(), o.getCField(), this::setCField);
			
			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;
		
			B5 _that = getType().cast(o);
		
			if (!Objects.equals(cField, _that.getCField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (cField != null ? cField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "B5Builder {" +
				"cField=" + this.cField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy