Class CreditorIdentifier

java.lang.Object
fr.marcwrobel.jbanking.creditor.CreditorIdentifier
All Implemented Interfaces:
Serializable

public final class CreditorIdentifier extends Object implements Serializable
A Creditor Identifier (CI) code as specified by the EPC.

The CI structure is:

  • Position 1-2 filled with the ISO country code.
  • Position 3-4 filled with the check digit according to ISO 7064 Mod 97-10.
  • Position 5-7 filled with the Creditor Business Code, if not used then filled with ZZZ.
  • Position 8 onwards filled with the country specific part of the identifier being a national identifier of the Creditor, as defined by the National Community.

This class handles validation of the check digit and validation of the Creditor Identifier Structure described above without going into the validation of the national identifier.

Instances of this class are immutable and thread-safe.

This class implements Serializable for convenience, but you are encouraged to use the normalized string representation if possible. Note that no validity check is done during deserialization.

Usage:

 // Validate a creditor identifier
 Assertions.assertTrue(CreditorIdentifier.isValid(" fr72zzz123456 "));

 // Get creditor identifier information
 CreditorIdentifier ci = new CreditorIdentifier(" fr72zzz123456 ");
 Assertions.assertEquals("FR72ZZZ123456", ci.toString());
 Assertions.assertEquals("FR", ci.getCountryCode());
 Assertions.assertEquals("72", ci.getCheckDigit());
 Assertions.assertEquals("ZZZ", ci.getBusinessCode());
 Assertions.assertEquals("123456", ci.getNationalIdentifier());
 
See Also:
  • Field Details

    • REGEX

      public static final String REGEX
      A simple regex that validate well-formed Creditor Identifiers.

      All strings accepted by isValid(String) are also accepted by this regex.

      See Also:
  • Constructor Details

  • Method Details

    • isValid

      public static boolean isValid(String s)
      Check whether the given string is a valid creditor identifier.

      This method is neither sensitive to the case nor to the presence of leading or trailing spaces.

      Parameters:
      s - a string, may be null
      Returns:
      true if the given String is a valid Creditor Identifier, false otherwise
    • getCountryCode

      public String getCountryCode()
      Extract the ISO 3166-1-alpha-2 country code from this Creditor Identifier.
      Returns:
      a non-null string representing this Creditor Identifier ISO 3166-1-alpha-2 country code
    • getCountry

      public IsoCountry getCountry()
      Gets this Creditor Identifier IsoCountry.
      Returns:
      a non-null IsoCountry
    • getCheckDigit

      public String getCheckDigit()
      Extract the check digit from this Creditor Identifier.
      Returns:
      a non-null string representing this Creditor Identifier check digit
    • getBusinessCode

      public String getBusinessCode()
      Extract the business code from this Creditor Identifier.
      Returns:
      a non-null string representing this Creditor Identifier business code
    • getNationalIdentifier

      public String getNationalIdentifier()
      Extract the creditor national identifier from this Creditor Identifier.
      Returns:
      a non-null string representing this Creditor Identifier National ID
    • toString

      public String toString()
      Returns a normalized string representation of this Creditor Identifier.

      Normalized means the string is:

      • made of uppercase characters
      • contains no spaces
      Overrides:
      toString in class Object
      Returns:
      a normalized string representation of this Creditor Identifier
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object