Package fr.marcwrobel.jbanking.bic
Class Bic
- java.lang.Object
-
- fr.marcwrobel.jbanking.bic.Bic
-
- All Implemented Interfaces:
Serializable
public final class Bic extends Object implements Serializable
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 BIC is either eight (BIC8) or eleven (BIC11) characters made up of :
- 4 letters: institution code (or bank code)
- 2 letters: ISO 3166-1 alpha-2 country code
- 2 letters or digits: location code
- 3 letters or digits (optional): branch code
This class is immutable.
- Since:
- 1.0
- Author:
- Marc Wrobel
- See Also:
- http://wikipedia.org/wiki/Bank_Identifier_Code, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PatternBIC_PATTERNA pre-compiled Pattern forBIC_REGEX.static StringBIC_REGEXA simple regex that validate well-formed BIC.static StringPRIMARY_OFFICE_BRANCH_CODEThe branch code for primary offices.static charTEST_BIC_INDICATORIf the last character of the location code in a BIC is this one it means that the BIC is a Test BIC,
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BicasTestBic()Transform this BIC to a test BIC.booleanequals(Object o)Indicates whether some other object is “equal to” this one.StringgetBranchCode()Extract the branch code from this BIC.StringgetCountryCode()Extract the country code from this BIC.StringgetInstitutionCode()Extract the institution code (or bank code) from this BIC.StringgetLocationCode()Extract the location code from this BIC.inthashCode()booleanisLiveBic()Test whether this BIC is a live bic.booleanisTestBic()Test whether this BIC is a test bic.static booleanisValid(String bic)Check whether the given string is valid BIC.StringtoString()Returns a normalized string representation of this BIC.
-
-
-
Field Detail
-
BIC_REGEX
public static final String BIC_REGEX
A simple regex that validate well-formed BIC.- See Also:
- Constant Field Values
-
PRIMARY_OFFICE_BRANCH_CODE
public static final String PRIMARY_OFFICE_BRANCH_CODE
The branch code for primary offices.- See Also:
- Constant Field Values
-
TEST_BIC_INDICATOR
public static final char TEST_BIC_INDICATOR
If the last character of the location code in a BIC is this one it means that the BIC is a Test BIC,- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Bic
public Bic(String bic8Or11)
Create a new bic from the given string.The given string may be a BIC8 or a BIC11.
- Parameters:
bic8Or11- A non-null String.- Throws:
IllegalArgumentException- if the given string is nullBicFormatException- if the given BIC8 or BIC11 string does not matchBIC_REGEXor if the given BIC8 or BIC11 country code is not known inIsoCountry.
-
-
Method Detail
-
isValid
public static boolean isValid(String bic)
Check whether the given string is valid BIC.- Parameters:
bic- A String.- Returns:
trueif the given string is valid BIC, otherwisefalse.
-
getInstitutionCode
public String getInstitutionCode()
Extract the institution code (or bank code) from this BIC.- Returns:
- A non-null string representing this BIC institution code.
-
getCountryCode
public String getCountryCode()
Extract the country code from this BIC.- Returns:
- A non-null string representing this BIC country code.
-
getLocationCode
public String getLocationCode()
Extract the location code from this BIC.- Returns:
- A non-null string representing this BIC location code.
-
getBranchCode
public String getBranchCode()
Extract the branch code from this BIC.- Returns:
- A non-null string representing this BIC branch code.
-
isTestBic
public boolean isTestBic()
Test whether this BIC is a test bic.A BIC is a test BIC if the last character of the location code is 48.
- Returns:
trueif this BIC is a test BIC, otherwisefalse.- See Also:
isLiveBic()
-
isLiveBic
public boolean isLiveBic()
Test whether this BIC is a live bic.A BIC is a live BIC if the last character of the location code is not 48.
- Returns:
trueif this BIC is a live BIC, otherwisefalse.- See Also:
isTestBic()
-
asTestBic
public Bic asTestBic()
Transform this BIC to a test BIC.- Returns:
- this if this BIC is a test BIC, or this BIC corresponding test BIC otherwise.
-
equals
public boolean equals(Object o)
Indicates whether some other object is “equal to” this one.To be equals to this one the other object must be a
Bicand the BICs normalized form (seetoString()) must be equal.- Overrides:
equalsin classObject- Parameters:
o- the object with which to compare.- Returns:
trueif this object is the same as the obj argument orfalseotherwise.- See Also:
Object.toString()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classObject- See Also:
Object.hashCode()
-
-