Class MxId


  • public class MxId
    extends java.lang.Object
    Class for identification of MX messages.

    It is composed by the business process (business area), functionality (message type), variant and version. For a better understanding of ISO 20022 variants check https://www.iso20022.org/variants page

    Since:
    7.7
    • Constructor Summary

      Constructors 
      Constructor Description
      MxId()  
      MxId​(MxBusinessProcess businessProcess, java.lang.String funString, java.lang.String varString, java.lang.String verString)  
      MxId​(java.lang.String namespace)
      Creates a new object getting data from an MX message namespace.
      MxId​(java.lang.String bpString, java.lang.String funString, java.lang.String varString, java.lang.String verString)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String camelized()  
      java.lang.String category()
      Get the category of the message, which is the business process name.
      boolean equals​(java.lang.Object o)
      Indicates whether some other object is "equal to" this one.
      MxBusinessProcess getBusinessProcess()
      Gets the business process (a.k.a.
      java.util.Optional<java.lang.String> getBusinessService()
      Get the optional business service, which could be an additional value to differentiate messages within the same message type.
      java.lang.String getFunctionality()
      Gets the functionality (a.k.a.
      int getFunctionalityInt()  
      java.lang.String getVariant()  
      int getVariantInt()  
      java.lang.String getVersion()  
      int getVersionInt()  
      int hashCode()
      Returns a hash code value for the object.
      java.lang.String id()
      Get a string in the form of businessprocess.functionality.variant.version
      boolean matches​(MxId other)
      Check if this identification matches another one.
      boolean matches​(java.lang.String namespace)
      Check if this identification matches the given namespace.
      java.lang.String namespaceURI()
      Creates the corresponding ISO 20022 namespace URI for this MX, for example: urn:swift:xsd:camt.003.001.04 All id attributes should be properly filled.
      MxId setBusinessProcess​(MxBusinessProcess businessProcess)  
      MxId setBusinessService​(java.lang.String businessService)
      Set the business service, which could be an additional value to differentiate messages within the same message type.
      MxId setFunctionality​(java.lang.String functionality)  
      MxId setVariant​(java.lang.String variant)  
      MxId setVersion​(java.lang.String version)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MxId

        public MxId()
      • MxId

        public MxId​(java.lang.String namespace)
        Creates a new object getting data from an MX message namespace.

        The implementation parses the namespace using a regex to detect the message type part.

        Parameters:
        namespace - a complete or partial namespace such as "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" or just "pain.001.001.03"
        Throws:
        java.lang.IllegalArgumentException - if namespace parameter cannot be parsed as MX identification
      • MxId

        public MxId​(MxBusinessProcess businessProcess,
                    java.lang.String funString,
                    java.lang.String varString,
                    java.lang.String verString)
      • MxId

        public MxId​(java.lang.String bpString,
                    java.lang.String funString,
                    java.lang.String varString,
                    java.lang.String verString)
    • Method Detail

      • getBusinessProcess

        public MxBusinessProcess getBusinessProcess()
        Gets the business process (a.k.a. business area)
        Returns:
        the business process set
      • getFunctionality

        public java.lang.String getFunctionality()
        Gets the functionality (a.k.a. message type)
        Returns:
        the functionality set
      • setFunctionality

        public MxId setFunctionality​(java.lang.String functionality)
      • getVariant

        public java.lang.String getVariant()
      • setVariant

        public MxId setVariant​(java.lang.String variant)
      • getVersion

        public java.lang.String getVersion()
      • setVersion

        public MxId setVersion​(java.lang.String version)
      • camelized

        public java.lang.String camelized()
      • getVersionInt

        public int getVersionInt()
      • getVariantInt

        public int getVariantInt()
      • getFunctionalityInt

        public int getFunctionalityInt()
      • namespaceURI

        public java.lang.String namespaceURI()
        Creates the corresponding ISO 20022 namespace URI for this MX, for example: urn:swift:xsd:camt.003.001.04 All id attributes should be properly filled.
        Returns:
        a string representing the namespace URI for the MX or null if any of the attributes is not set
      • id

        public java.lang.String id()
        Get a string in the form of businessprocess.functionality.variant.version
        Returns:
        a string with the MX message type identification or null if any of the properties is null
        Since:
        7.7
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether some other object is "equal to" this one.

        Overrides the default implementation of Object.equals(Object). This method considers two MxId objects equal if their businessProcess, functionality, variant, and version fields are equal.

        Notice the business service field is not included in the comparison.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the reference object with which to compare
        Returns:
        true if this object is the same as the obj argument; false otherwise
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.

        Overrides the default implementation of Object.hashCode(). This method generates a hash code based on the businessProcess, functionality, variant, and version fields.

        Notice the business service field is not included in the hash code calculation.

        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object
      • matches

        public boolean matches​(java.lang.String namespace)
        Check if this identification matches the given namespace.

        This is particularly useful if this identifier is not completely filled, for example: if the business process is set to "pain" and the functionality is set to "002" but the variant and version are left null, then this identifier will match any namespace containing pain.002.*.* where the wildcard could be any number.
        new MxId("pain", "002", null, null).matches("pain.002.001.03") will be true.

        Parameters:
        namespace - a complete or partial namespace such as "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" or just "pain.001.001.03"
        Returns:
        true if this id matches the parameter
        Throws:
        java.lang.IllegalArgumentException - if namespace parameter cannot be parsed as MX identification
        Since:
        7.10.7
      • matches

        public boolean matches​(MxId other)
        Check if this identification matches another one.

        This is particularly useful if this identifier is not completely filled, for example: if the business process is set to "pain" and the functionality is set to "002" but the variant and version are left null, then this identifier will match for example both pain.002.001.03 and pain.002.002.04.

        The difference between this implementation and equals(Object) is that here null and empty properties are treated as equals. Meaning it is not sensible to null versus blank properties, thus pain.001.001.null will match pain.001.001.empty.

        Parameters:
        other - an identification to compare
        Returns:
        true if this id matches the parameter
        Throws:
        java.lang.IllegalArgumentException - if namespace parameter cannot be parsed as MX identification
        Since:
        7.10.7
      • category

        public java.lang.String category()
        Get the category of the message, which is the business process name.
        Returns:
        the business process name or null if not set
        Since:
        9.5.0
      • getBusinessService

        public java.util.Optional<java.lang.String> getBusinessService()
        Get the optional business service, which could be an additional value to differentiate messages within the same message type. For example "swift.cbprplus.cov.02". Notice when the MxId is created from the namespace this value is not set. This value must be set manually by the application when the MxId is extracted from a whole message and the AppHdr is available. Alternatively, the application can set this value with any other context information and use it as a discriminator.
        Returns:
        the business service value or null if not set
        Since:
        9.5.0
      • setBusinessService

        public MxId setBusinessService​(java.lang.String businessService)
        Set the business service, which could be an additional value to differentiate messages within the same message type. This is mainly intended to contain the business services from the message AppHdr, but could potentially be used to hold any other value that helps to differentiate messages within the same message type.
        Parameters:
        businessService - a string value to set as discriminator, for example "swift.cbprplus.cov.02"
        Since:
        9.5.0