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

org.isda.cdm.TestPartyIdentifier Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package org.isda.cdm;

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.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.FieldWithMetaString.FieldWithMetaStringBuilder;
import java.util.Objects;
import org.isda.cdm.TestPartyIdentifier;
import org.isda.cdm.TestPartyIdentifier.TestPartyIdentifierBuilder;
import org.isda.cdm.TestPartyIdentifier.TestPartyIdentifierBuilderImpl;
import org.isda.cdm.TestPartyIdentifier.TestPartyIdentifierImpl;
import org.isda.cdm.meta.TestPartyIdentifierMeta;

import static java.util.Optional.ofNullable;

/**
 * The set of [partyId, PartyIdSource] associated with a party.
 * @version test
 */
@RosettaDataType(value="TestPartyIdentifier", builder=TestPartyIdentifier.TestPartyIdentifierBuilderImpl.class, version="test")
public interface TestPartyIdentifier extends RosettaModelObject {

	TestPartyIdentifierMeta metaData = new TestPartyIdentifierMeta();

	/*********************** Getter Methods  ***********************/
	/**
	 * The identifier associated with a party, e.g. the 20 digits LEI code.
	 */
	FieldWithMetaString getPartyId();

	/*********************** Build Methods  ***********************/
	TestPartyIdentifier build();
	
	TestPartyIdentifier.TestPartyIdentifierBuilder toBuilder();
	
	static TestPartyIdentifier.TestPartyIdentifierBuilder builder() {
		return new TestPartyIdentifier.TestPartyIdentifierBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return TestPartyIdentifier.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("partyId"), processor, FieldWithMetaString.class, getPartyId());
	}
	

	/*********************** Builder Interface  ***********************/
	interface TestPartyIdentifierBuilder extends TestPartyIdentifier, RosettaModelObjectBuilder {
		FieldWithMetaString.FieldWithMetaStringBuilder getOrCreatePartyId();
		FieldWithMetaString.FieldWithMetaStringBuilder getPartyId();
		TestPartyIdentifier.TestPartyIdentifierBuilder setPartyId(FieldWithMetaString partyId0);
		TestPartyIdentifier.TestPartyIdentifierBuilder setPartyIdValue(String partyId1);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("partyId"), processor, FieldWithMetaString.FieldWithMetaStringBuilder.class, getPartyId());
		}
		

		TestPartyIdentifier.TestPartyIdentifierBuilder prune();
	}

	/*********************** Immutable Implementation of TestPartyIdentifier  ***********************/
	class TestPartyIdentifierImpl implements TestPartyIdentifier {
		private final FieldWithMetaString partyId;
		
		protected TestPartyIdentifierImpl(TestPartyIdentifier.TestPartyIdentifierBuilder builder) {
			this.partyId = ofNullable(builder.getPartyId()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("partyId")
		public FieldWithMetaString getPartyId() {
			return partyId;
		}
		
		@Override
		public TestPartyIdentifier build() {
			return this;
		}
		
		@Override
		public TestPartyIdentifier.TestPartyIdentifierBuilder toBuilder() {
			TestPartyIdentifier.TestPartyIdentifierBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(TestPartyIdentifier.TestPartyIdentifierBuilder builder) {
			ofNullable(getPartyId()).ifPresent(builder::setPartyId);
		}

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

	/*********************** Builder Implementation of TestPartyIdentifier  ***********************/
	class TestPartyIdentifierBuilderImpl implements TestPartyIdentifier.TestPartyIdentifierBuilder {
	
		protected FieldWithMetaString.FieldWithMetaStringBuilder partyId;
	
		public TestPartyIdentifierBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("partyId")
		public FieldWithMetaString.FieldWithMetaStringBuilder getPartyId() {
			return partyId;
		}
		
		@Override
		public FieldWithMetaString.FieldWithMetaStringBuilder getOrCreatePartyId() {
			FieldWithMetaString.FieldWithMetaStringBuilder result;
			if (partyId!=null) {
				result = partyId;
			}
			else {
				result = partyId = FieldWithMetaString.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("partyId")
		public TestPartyIdentifier.TestPartyIdentifierBuilder setPartyId(FieldWithMetaString partyId) {
			this.partyId = partyId==null?null:partyId.toBuilder();
			return this;
		}
		@Override
		public TestPartyIdentifier.TestPartyIdentifierBuilder setPartyIdValue(String partyId) {
			this.getOrCreatePartyId().setValue(partyId);
			return this;
		}
		
		@Override
		public TestPartyIdentifier build() {
			return new TestPartyIdentifier.TestPartyIdentifierImpl(this);
		}
		
		@Override
		public TestPartyIdentifier.TestPartyIdentifierBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public TestPartyIdentifier.TestPartyIdentifierBuilder prune() {
			if (partyId!=null && !partyId.prune().hasData()) partyId = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getPartyId()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public TestPartyIdentifier.TestPartyIdentifierBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			TestPartyIdentifier.TestPartyIdentifierBuilder o = (TestPartyIdentifier.TestPartyIdentifierBuilder) other;
			
			merger.mergeRosetta(getPartyId(), o.getPartyId(), this::setPartyId);
			
			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;
		
			TestPartyIdentifier _that = getType().cast(o);
		
			if (!Objects.equals(partyId, _that.getPartyId())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (partyId != null ? partyId.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "TestPartyIdentifierBuilder {" +
				"partyId=" + this.partyId +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy