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

com.rosetta.testother.model.Contract 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.ContProd;
import com.rosetta.testother.model.Contract;
import com.rosetta.testother.model.Contract.ContractBuilder;
import com.rosetta.testother.model.Contract.ContractBuilderImpl;
import com.rosetta.testother.model.Contract.ContractImpl;
import com.rosetta.testother.model.meta.ContractMeta;
import java.util.Objects;

import static java.util.Optional.ofNullable;

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

	ContractMeta metaData = new ContractMeta();

	/*********************** Getter Methods  ***********************/
	ContProd getContProd();

	/*********************** Build Methods  ***********************/
	Contract build();
	
	Contract.ContractBuilder toBuilder();
	
	static Contract.ContractBuilder builder() {
		return new Contract.ContractBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Contract.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("contProd"), processor, ContProd.class, getContProd());
	}
	

	/*********************** Builder Interface  ***********************/
	interface ContractBuilder extends Contract, RosettaModelObjectBuilder {
		ContProd.ContProdBuilder getOrCreateContProd();
		ContProd.ContProdBuilder getContProd();
		Contract.ContractBuilder setContProd(ContProd contProd);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("contProd"), processor, ContProd.ContProdBuilder.class, getContProd());
		}
		

		Contract.ContractBuilder prune();
	}

	/*********************** Immutable Implementation of Contract  ***********************/
	class ContractImpl implements Contract {
		private final ContProd contProd;
		
		protected ContractImpl(Contract.ContractBuilder builder) {
			this.contProd = ofNullable(builder.getContProd()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("contProd")
		public ContProd getContProd() {
			return contProd;
		}
		
		@Override
		public Contract build() {
			return this;
		}
		
		@Override
		public Contract.ContractBuilder toBuilder() {
			Contract.ContractBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Contract.ContractBuilder builder) {
			ofNullable(getContProd()).ifPresent(builder::setContProd);
		}

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

	/*********************** Builder Implementation of Contract  ***********************/
	class ContractBuilderImpl implements Contract.ContractBuilder {
	
		protected ContProd.ContProdBuilder contProd;
	
		public ContractBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("contProd")
		public ContProd.ContProdBuilder getContProd() {
			return contProd;
		}
		
		@Override
		public ContProd.ContProdBuilder getOrCreateContProd() {
			ContProd.ContProdBuilder result;
			if (contProd!=null) {
				result = contProd;
			}
			else {
				result = contProd = ContProd.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("contProd")
		public Contract.ContractBuilder setContProd(ContProd contProd) {
			this.contProd = contProd==null?null:contProd.toBuilder();
			return this;
		}
		
		@Override
		public Contract build() {
			return new Contract.ContractImpl(this);
		}
		
		@Override
		public Contract.ContractBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Contract.ContractBuilder prune() {
			if (contProd!=null && !contProd.prune().hasData()) contProd = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getContProd()!=null && getContProd().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Contract.ContractBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Contract.ContractBuilder o = (Contract.ContractBuilder) other;
			
			merger.mergeRosetta(getContProd(), o.getContProd(), this::setContProd);
			
			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;
		
			Contract _that = getType().cast(o);
		
			if (!Objects.equals(contProd, _that.getContProd())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (contProd != null ? contProd.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "ContractBuilder {" +
				"contProd=" + this.contProd +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy