Package fr.marcwrobel.jbanking.creditor
Class CreditorIdentifier
java.lang.Object
fr.marcwrobel.jbanking.creditor.CreditorIdentifier
- All Implemented Interfaces:
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());
-
Constructor Summary
ConstructorsConstructorDescriptionCreditorIdentifier(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.CreditorIdentifier(String creditorId) Create a new creditor identifier from the given string. -
Method Summary
Modifier and TypeMethodDescriptionbooleanExtract the business code from this Creditor Identifier.Extract the check digit from this Creditor Identifier.Extract the ISO 3166-1-alpha-2 country code from this Creditor Identifier.Extract the creditor national identifier from this Creditor Identifier.inthashCode()static booleanValidates the given Creditor Identifier String.toString()
-
Constructor Details
-
CreditorIdentifier
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 isnullCreditorIdentifierFormatException- if a valid Creditor Identifier could not be calculated using the given IsoCountry, business code and creditor national id
-
CreditorIdentifier
Create a new creditor identifier from the given string.- Parameters:
creditorId- a non-null String.
-
-
Method Details
-
isValid
Validates the given Creditor Identifier String.- Parameters:
creditorIdentifier- A String.- Returns:
trueif the given String is a valid Creditor Identifier,falseotherwise.
-
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
Extract the check digit from this Creditor Identifier.- Returns:
- A non-null string representing this Creditor Identifier check digit.
-
getBusinessCode
Extract the business code from this Creditor Identifier.- Returns:
- A non-null string representing this Creditor Identifier business code.
-
getNationalIdentifier
Extract the creditor national identifier from this Creditor Identifier.- Returns:
- A non-null string representing this Creditor Identifier National ID.
-
toString
-
equals
-
hashCode
public int hashCode()
-