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

com.rosetta.testother.model.A7 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testother.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.testother.model.A7;
import com.rosetta.testother.model.A7.A7Builder;
import com.rosetta.testother.model.A7.A7BuilderImpl;
import com.rosetta.testother.model.A7.A7Impl;
import com.rosetta.testother.model.B7;
import com.rosetta.testother.model.meta.A7Meta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	A7Meta metaData = new A7Meta();

	/*********************** Getter Methods  ***********************/
	B7 getBField();

	/*********************** Build Methods  ***********************/
	A7 build();
	
	A7.A7Builder toBuilder();
	
	static A7.A7Builder builder() {
		return new A7.A7BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return A7.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("bField"), processor, B7.class, getBField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface A7Builder extends A7, RosettaModelObjectBuilder {
		B7.B7Builder getOrCreateBField();
		B7.B7Builder getBField();
		A7.A7Builder setBField(B7 bField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("bField"), processor, B7.B7Builder.class, getBField());
		}
		

		A7.A7Builder prune();
	}

	/*********************** Immutable Implementation of A7  ***********************/
	class A7Impl implements A7 {
		private final B7 bField;
		
		protected A7Impl(A7.A7Builder builder) {
			this.bField = ofNullable(builder.getBField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("bField")
		public B7 getBField() {
			return bField;
		}
		
		@Override
		public A7 build() {
			return this;
		}
		
		@Override
		public A7.A7Builder toBuilder() {
			A7.A7Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(A7.A7Builder builder) {
			ofNullable(getBField()).ifPresent(builder::setBField);
		}

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

	/*********************** Builder Implementation of A7  ***********************/
	class A7BuilderImpl implements A7.A7Builder {
	
		protected B7.B7Builder bField;
	
		public A7BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("bField")
		public B7.B7Builder getBField() {
			return bField;
		}
		
		@Override
		public B7.B7Builder getOrCreateBField() {
			B7.B7Builder result;
			if (bField!=null) {
				result = bField;
			}
			else {
				result = bField = B7.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("bField")
		public A7.A7Builder setBField(B7 bField) {
			this.bField = bField==null?null:bField.toBuilder();
			return this;
		}
		
		@Override
		public A7 build() {
			return new A7.A7Impl(this);
		}
		
		@Override
		public A7.A7Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A7.A7Builder prune() {
			if (bField!=null && !bField.prune().hasData()) bField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getBField()!=null && getBField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public A7.A7Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			A7.A7Builder o = (A7.A7Builder) other;
			
			merger.mergeRosetta(getBField(), o.getBField(), this::setBField);
			
			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;
		
			A7 _that = getType().cast(o);
		
			if (!Objects.equals(bField, _that.getBField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (bField != null ? bField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "A7Builder {" +
				"bField=" + this.bField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy