Class CreditorIdentifier

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

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

CI structure:

  • 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.

Usage:

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

 // Retrieve 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:
  • Constructor Details

    • CreditorIdentifier

      public CreditorIdentifier(IsoCountry country, String businessCode, String creditorNationalId)
      Create a new Creditor Identifier from the given country code, the creditor business code and the creditor national id.
      Parameters:
      country - A non-null IsoCountry.
      businessCode - A non-null String.
      creditorNationalId - A non-null String.
      Throws:
      IllegalArgumentException - if either the IsoCountry or BBAN is null
      CreditorIdentifierFormatException - if a valid Creditor Identifier could not be calculated using the given IsoCountry, business code and creditor national id
    • CreditorIdentifier

      public CreditorIdentifier(String creditorId)
      Create a new creditor identifier from the given string.
      Parameters:
      creditorId - a non-null String.
  • Method Details

    • isValid

      public static boolean isValid(String creditorIdentifier)
      Validates the given Creditor Identifier String.
      Parameters:
      creditorIdentifier - A String.
      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.
    • 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()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object