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

com.rosetta.metatest.model.Intermediate Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.metatest.model;

import com.rosetta.metatest.model.Intermediate;
import com.rosetta.metatest.model.Intermediate.IntermediateBuilder;
import com.rosetta.metatest.model.Intermediate.IntermediateBuilderImpl;
import com.rosetta.metatest.model.Intermediate.IntermediateImpl;
import com.rosetta.metatest.model.Party1;
import com.rosetta.metatest.model.meta.IntermediateMeta;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaParty1;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder;
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 java.util.Objects;

import static java.util.Optional.ofNullable;

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

	IntermediateMeta metaData = new IntermediateMeta();

	/*********************** Getter Methods  ***********************/
	ReferenceWithMetaParty1 getParty();

	/*********************** Build Methods  ***********************/
	Intermediate build();
	
	Intermediate.IntermediateBuilder toBuilder();
	
	static Intermediate.IntermediateBuilder builder() {
		return new Intermediate.IntermediateBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Intermediate.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("party"), processor, ReferenceWithMetaParty1.class, getParty());
	}
	

	/*********************** Builder Interface  ***********************/
	interface IntermediateBuilder extends Intermediate, RosettaModelObjectBuilder {
		ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getOrCreateParty();
		ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getParty();
		Intermediate.IntermediateBuilder setParty(ReferenceWithMetaParty1 party0);
		Intermediate.IntermediateBuilder setPartyValue(Party1 party1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("party"), processor, ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder.class, getParty());
		}
		

		Intermediate.IntermediateBuilder prune();
	}

	/*********************** Immutable Implementation of Intermediate  ***********************/
	class IntermediateImpl implements Intermediate {
		private final ReferenceWithMetaParty1 party;
		
		protected IntermediateImpl(Intermediate.IntermediateBuilder builder) {
			this.party = ofNullable(builder.getParty()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("party")
		public ReferenceWithMetaParty1 getParty() {
			return party;
		}
		
		@Override
		public Intermediate build() {
			return this;
		}
		
		@Override
		public Intermediate.IntermediateBuilder toBuilder() {
			Intermediate.IntermediateBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Intermediate.IntermediateBuilder builder) {
			ofNullable(getParty()).ifPresent(builder::setParty);
		}

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

	/*********************** Builder Implementation of Intermediate  ***********************/
	class IntermediateBuilderImpl implements Intermediate.IntermediateBuilder {
	
		protected ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder party;
	
		public IntermediateBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("party")
		public ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getParty() {
			return party;
		}
		
		@Override
		public ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder getOrCreateParty() {
			ReferenceWithMetaParty1.ReferenceWithMetaParty1Builder result;
			if (party!=null) {
				result = party;
			}
			else {
				result = party = ReferenceWithMetaParty1.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("party")
		public Intermediate.IntermediateBuilder setParty(ReferenceWithMetaParty1 party) {
			this.party = party==null?null:party.toBuilder();
			return this;
		}
		@Override
		public Intermediate.IntermediateBuilder setPartyValue(Party1 party) {
			this.getOrCreateParty().setValue(party);
			return this;
		}
		
		@Override
		public Intermediate build() {
			return new Intermediate.IntermediateImpl(this);
		}
		
		@Override
		public Intermediate.IntermediateBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Intermediate.IntermediateBuilder prune() {
			if (party!=null && !party.prune().hasData()) party = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getParty()!=null && getParty().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Intermediate.IntermediateBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Intermediate.IntermediateBuilder o = (Intermediate.IntermediateBuilder) other;
			
			merger.mergeRosetta(getParty(), o.getParty(), this::setParty);
			
			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;
		
			Intermediate _that = getType().cast(o);
		
			if (!Objects.equals(party, _that.getParty())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (party != null ? party.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "IntermediateBuilder {" +
				"party=" + this.party +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy