Skip to content

Commit

Permalink
Fix Bic, CreditorIdentifier and Iban documentation (#209)
Browse files Browse the repository at this point in the history
It was not explicit that lowercase characters were accepted.
  • Loading branch information
marcwrobel committed Oct 15, 2022
1 parent b5ce1b5 commit 4725a84
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- (**breaking change**) `Iban.isValid(String)` or `IbanCheckDigit.validate(String)` return `false` instead of raising an
`IllegalArgumentException` with invalid IBAN check digit (e.g. `00`, `01`, or `99`).
- Fix `Bic`, `CreditorIdentifier` and `Iban` documentation (#209). It was not explicit that lowercase characters were
accepted.

### Deprecated

Expand Down
21 changes: 12 additions & 9 deletions src/main/java/fr/marcwrobel/jbanking/bic/Bic.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.util.Optional;

/**
* A Business Identifier Code (also known as BIC, SWIFT-BIC, BIC code, SWIFT ID or SWIFT code, Business Entity Identifier or
* BEI) as specified by ISO 9362:2009.
* A Business Identifier Code (also known as BIC, SWIFT-BIC, BIC code, SWIFT ID or SWIFT code, Business Entity
* Identifier or BEI) as specified by ISO 9362:2009.
*
* <p>
* A BIC is either eight (BIC8) or eleven (BIC11) characters made up of :
Expand All @@ -20,8 +20,8 @@
* </ul>
*
* <p>
* Where an 8-digit code is given, it is assumed that it refers to the primary office. The primary office is always designated
* by the branch code {@value #PRIMARY_OFFICE_BRANCH_CODE}).
* Where an 8-digit code is given, it is assumed that it refers to the primary office. The primary office is always
* designated by the branch code {@value #PRIMARY_OFFICE_BRANCH_CODE}).
*
* <p>
* Instances of this class are immutable and thread-safe.
Expand Down Expand Up @@ -86,10 +86,10 @@ public final class Bic implements Serializable {
private final String normalizedBic;

/**
* Create a new bic from the given string.
* Create a new BIC from the given string.
*
* <p>
* The given string may be a BIC8 or a BIC11.
* The given string may be a BIC8 or a BIC11. Uppercase and lowercase characters are accepted.
*
* @param bic8Or11 A non-null String.
* @throws IllegalArgumentException if the given string is {@code null}
Expand Down Expand Up @@ -118,7 +118,10 @@ public Bic(final String bic8Or11) {
}

/**
* Check whether the given string is valid BIC.
* Check whether the given string is a valid BIC.
*
* <p>
* The given string may be a BIC8 or a BIC11. Uppercase and lowercase characters are considered valid.
*
* @param bic A String.
* @return {@code true} if the given string is valid BIC, otherwise {@code false}.
Expand Down Expand Up @@ -242,8 +245,8 @@ public Bic asTestBic() {
* Indicates whether some other object is “equal to” this one.
*
* <p>
* To be equals to this one the other object must be a {@link Bic} and the BICs normalized form (see {@link #toString()}) must
* be equal.
* To be equals to this one the other object must be a {@link Bic} and the BICs normalized form (see
* {@link #toString()}) must be equal.
*
* @param o the object with which to compare.
* @return {@code true} if this object is the same as the obj argument or {@code false} otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@

/**
* A Creditor Identifier (CI) code as specified by the
* <a href="https://www.europeanpaymentscouncil.eu/document-library/guidance-documents/creditor-identifier-overview">EPC</a>.
* <a href="https://www.europeanpaymentscouncil.eu/document-library/guidance-documents/creditor-identifier-overview">
* EPC</a>.
*
* <p>
* CI structure:
* The CI structure is:
*
* <ul>
* <li>Position 1-2 filled with the ISO country code.
* <li>Position 3-4 filled with the check digit according to ISO 7064 Mod 97-10.
* <li>Position 5-7 filled with the Creditor Business Code, if not used then filled with ZZZ.
* <li>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.
* <li>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.
* </ul>
*
* <p>
* 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.
* 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.
*
* <p>
* Instances of this class are immutable and thread-safe.
Expand All @@ -44,8 +45,8 @@
* Assertions.assertEquals("123456", ci.getNationalIdentifier());
* </pre>
*
* @see <a href="https://www.europeanpaymentscouncil.eu/document-library/guidance-documents/creditor-identifier-overview">EPC
* Creditor Identifier Overview</a>
* @see <a href="https://www.europeanpaymentscouncil.eu/document-library/guidance-documents/creditor-identifier-overview">
* EPC Creditor Identifier Overview</a>
*/
public final class CreditorIdentifier implements Serializable {

Expand Down Expand Up @@ -77,10 +78,13 @@ public final class CreditorIdentifier implements Serializable {
/**
* Create a new Creditor Identifier from the given string.
*
* <p>
* Uppercase and lowercase characters are accepted.
*
* @param creditorId A non-null String.
* @throws IllegalArgumentException if the given string is {@code null}
* @throws CreditorIdentifierFormatException if the given string does not match {@value #REGEX} or if its country code is not
* known in {@link fr.marcwrobel.jbanking.IsoCountry} or if its check digit is wrong
* @throws CreditorIdentifierFormatException if the given string does not match {@value #REGEX} or if its country code
* is not known in {@link fr.marcwrobel.jbanking.IsoCountry} or if its check digit is wrong
*/
public CreditorIdentifier(String creditorId) {
if (creditorId == null) {
Expand All @@ -107,10 +111,11 @@ public CreditorIdentifier(String creditorId) {
}

/**
* Create a new Creditor Identifier from the given country code, the creditor business code and the creditor national id.
* Create a new Creditor Identifier from the given country code, the creditor business code and the creditor national
* identifier.
*
* <p>
* The check digit is automatically calculated.
* The check digit is automatically calculated. Uppercase and lowercase characters are accepted.
*
* @param country A non-null IsoCountry.
* @param businessCode A non-null String.
Expand Down Expand Up @@ -185,9 +190,12 @@ private static String removeBusinessCode(String creditorIdentifier) {
}

/**
* Validates the given Creditor Identifier String.
* Check whether the given string is a valid creditor identifier.
*
* @param creditorIdentifier A String.
* <p>
* Uppercase and lowercase characters are considered valid.
*
* @param creditorIdentifier a String.
* @return {@code true} if the given String is a valid Creditor Identifier, {@code false} otherwise.
*/
public static boolean isValid(String creditorIdentifier) {
Expand All @@ -196,7 +204,6 @@ public static boolean isValid(String creditorIdentifier) {
}

String normalizedCreditorId = normalize(creditorIdentifier);

if (!isWellFormatted(normalizedCreditorId)) {
return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/fr/marcwrobel/jbanking/iban/Iban.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public final class Iban implements Serializable {
/**
* Create a new IBAN from the given country code and BBAN.
*
* <p>
* Uppercase and lowercase characters are accepted.
*
* @param country A non-null IsoCountry.
* @param bban A non-null String.
* @throws IllegalArgumentException if either the IsoCountry or BBAN is {@code null}
Expand Down Expand Up @@ -106,6 +109,9 @@ public Iban(IsoCountry country, String bban) {
/**
* Create a new IBAN from the given string.
*
* <p>
* Uppercase and lowercase characters are accepted.
*
* @param iban A non-null String.
* @throws IllegalArgumentException if the given string is {@code null}
* @throws IbanFormatException if the given string is not a valid IBAN.
Expand Down Expand Up @@ -141,6 +147,9 @@ public Iban(String iban) {
/**
* Validates the given IBAN String.
*
* <p>
* Uppercase and lowercase characters are considered valid.
*
* @param iban A String.
* @return {@code true} if the given String is a valid IBAN, {@code false} otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static boolean isAlphabetic(final char c) {

/**
* <p>
* Checks whether the character is ASCII 7 bit alphabetic upper case.
* Checks whether the character is ASCII 7 bit alphabetic uppercase.
* </p>
*
* <pre>
Expand All @@ -54,7 +54,7 @@ public static boolean isUpperAlphabetic(final char c) {

/**
* <p>
* Checks whether the character is ASCII 7 bit alphabetic lower case.
* Checks whether the character is ASCII 7 bit alphabetic lowercase.
* </p>
*
* <pre>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/marcwrobel/jbanking/swift/SwiftPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* </tr>
* <tr>
* <td>c</td>
* <td>upper and lower case alphanumeric characters (A-Z, a-z and 0-9)</td>
* <td>uppercase and lowercase alphanumeric characters (A-Z, a-z and 0-9)</td>
* </tr>
* <tr>
* <td>e</td>
Expand All @@ -58,7 +58,7 @@
*
* <ul>
* <li>{@code 4!n} : four digits
* <li>{@code 4!c3!a} : four upper or lower case alphanumeric characters followed by three upper case
* <li>{@code 4!c3!a} : four uppercase or lowercase alphanumeric characters followed by three upper case
* letters
* <li>{@code 2!e4!a} : two spaces followed by four upper case letters
* </ul>
Expand Down

0 comments on commit 4725a84

Please sign in to comment.