|
| 1 | +**Welcome to IBAN Commons!** |
| 2 | + |
| 3 | +IBAN Commons is our zero-dependency, ultra-fast, low-memory IBAN and BIC toolkit with a small, concise API. |
| 4 | + |
| 5 | +[](https://www.apache.org/licenses/LICENSE-2.0) |
| 6 | +[](https://www.google.com/search?q=https://central.sonatype.com/artifact/de.speedbanking/iban-commons) |
| 7 | +[](https://www.google.com/search?q=pom.xml) |
| 8 | + |
| 9 | +The `iban-commons` library provides simple, fast, and reliable validation and decomposition of International Bank Account Numbers (**IBAN**) and Business Identifier Codes (**BIC**). Designed for high-performance enterprise applications, it intentionally has **zero compile or runtime dependencies** outside of the Java Standard Library. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +) |
| 14 | +) |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +----- |
| 19 | + |
| 20 | +## 🚀 Key Features |
| 21 | + |
| 22 | + * **Zero Dependencies** |
| 23 | + |
| 24 | + Keep your build clean and avoid dependency conflicts |
| 25 | + |
| 26 | + * **High Performance** |
| 27 | + |
| 28 | + Optimized for execution speed and minimum memory footprint |
| 29 | + |
| 30 | + * **Small Footprint** |
| 31 | + |
| 32 | + ~100 kB JAR |
| 33 | + |
| 34 | + * **Simple, intuitive API** |
| 35 | + |
| 36 | + Intuitive factory methods (`Iban.of()`, `Bic.tryParse()`), clear component accessors |
| 37 | + |
| 38 | + * **Immutability** |
| 39 | + |
| 40 | + Both `Iban` and `Bic` classes are immutable and thread-safe |
| 41 | + |
| 42 | + * **Java 8 compatibility** |
| 43 | + |
| 44 | + Built with and compiled for Java 8 for maximum reach, tested on recent LTS versions |
| 45 | + |
| 46 | + * **Comprehensive** |
| 47 | + |
| 48 | + Full support for IBAN and BIC validation according to ISO standards |
| 49 | + |
| 50 | +----- |
| 51 | + |
| 52 | +## 🛠️ Usage |
| 53 | + |
| 54 | +### Maven Dependency |
| 55 | + |
| 56 | +Add the following to your project's `pom.xml`: |
| 57 | + |
| 58 | +```xml |
| 59 | +<dependency> |
| 60 | + <groupId>de.speedbanking</groupId> |
| 61 | + <artifactId>iban-commons</artifactId> |
| 62 | + <version>1.8.0</version> |
| 63 | +</dependency> |
| 64 | +``` |
| 65 | + |
| 66 | +### Gradle Dependency |
| 67 | + |
| 68 | +Add this line to your project's `build.gradle` or `build.gradle.kts`: |
| 69 | + |
| 70 | +``` |
| 71 | +implementation 'de.speedbanking:iban-commons:1.8.0' |
| 72 | +``` |
| 73 | + |
| 74 | +----- |
| 75 | + |
| 76 | +## 💡 Code Examples |
| 77 | + |
| 78 | +The API is designed for simplicity, focusing on two main ways to create a valid object: a throwing factory method for quick use and a safe parsing method using `Optional`. |
| 79 | + |
| 80 | +### IBAN |
| 81 | + |
| 82 | +The `Iban` class implements `Serializable`, `CharSequence`, and `Comparable<Iban>`. |
| 83 | + |
| 84 | +#### 1\. Quick Validation (throws exception on failure) |
| 85 | + |
| 86 | +Use `Iban.of()` or `Iban.parse()` when you prefer an exception for validation failures. |
| 87 | + |
| 88 | +```java |
| 89 | +import de.speedbanking.iban.Iban; |
| 90 | +import de.speedbanking.iban.InvalidIbanException; |
| 91 | + |
| 92 | +String ibanInput = "DE91100000000123456789"; |
| 93 | + |
| 94 | +try { |
| 95 | + Iban iban = Iban.of(ibanInput); |
| 96 | + |
| 97 | + // getters |
| 98 | + println("Country Code: " + iban.getCountryCode()); // DE |
| 99 | + println("Check Digits: " + iban.getCheckDigits()); // 91 |
| 100 | + println("BBAN : " + iban.getBban()); // 100000000123456789 |
| 101 | + println("Bank Code : " + iban.getBankCode()); // 10000000 |
| 102 | + println("Account No : " + iban.getAccountNumber()); // 0123456789 |
| 103 | + |
| 104 | + // output |
| 105 | + println("Normalized : " + iban.toString()); // DE91100000000123456789 |
| 106 | + println("Formatted : " + iban.toFormattedString()); // DE91 1000 0000 0123 4567 89 |
| 107 | + |
| 108 | +} catch (InvalidIbanException ex) { |
| 109 | + println("IBAN validation failed: " + ex.getMessage()); |
| 110 | +} |
| 111 | + |
| 112 | +static void println(String s) { System.out.println(s); } |
| 113 | + |
| 114 | +``` |
| 115 | + |
| 116 | +#### 2\. Safe Parsing (returns Optional) |
| 117 | + |
| 118 | +Use `Iban.tryParse()` when dealing with external or uncertain input and to avoid exceptions for control flow. |
| 119 | + |
| 120 | +```java |
| 121 | +import de.speedbanking.iban.Iban; |
| 122 | +import java.util.Optional; |
| 123 | + |
| 124 | +Optional<Iban> optionalIban = Iban.tryParse("PS92PALS000000000400123456702"); |
| 125 | + |
| 126 | +optionalIban.ifPresent(iban -> { |
| 127 | + println("Country Code: " + iban.getCountryCode()); // PS |
| 128 | + println("Country Name: " + iban.getCountryName()); // Palestine |
| 129 | + println("Country Flag: " + iban.getCountryFlag()); // 🇵🇸 |
| 130 | + println("Organisation: " + iban.getOrganisation()); // Palestine Monetary Authority |
| 131 | +}); |
| 132 | +``` |
| 133 | + |
| 134 | +----- |
| 135 | + |
| 136 | +### BIC |
| 137 | + |
| 138 | +The `Bic` class implements `Serializable`, `CharSequence`, and `Comparable<Bic>`. |
| 139 | +A BIC comparison is always based on the 11-character representation (`toBic11()`), meaning BIC-8 and its BIC-11 equivalent are considered equal. |
| 140 | + |
| 141 | +#### 1\. Quick Validation (throws exception on failure) |
| 142 | + |
| 143 | +```java |
| 144 | +import de.speedbanking.bic.Bic; |
| 145 | + |
| 146 | +// BIC-11 |
| 147 | +Bic bic11 = Bic.of("PALSPS22XXX"); // Bank of Palestine P.S.C. |
| 148 | + |
| 149 | +println("Bank Code : " + bic11.getBankCode()); // PALS |
| 150 | +println("Country Code : " + bic11.getCountryCode()); // PS |
| 151 | +println("Location Code: " + bic11.getLocationCode()); // 22 |
| 152 | +println("Branch Code : " + bic11.getBranchCode()); // XXX |
| 153 | +println("is BIC-11 : " + bic11.isBic11()); // true |
| 154 | +println("is BIC-8 : " + bic11.isBic8()); // false |
| 155 | +println("to BIC-8 : " + bic11.toBic8()); // PALSPS22 |
| 156 | + |
| 157 | +// BIC-8 |
| 158 | +Bic bic8 = Bic.of("MARKDEFF"); // Deutsche Bundesbank, Zentrale |
| 159 | + |
| 160 | +println("is BIC-8 : " + bic8.isBic8()); // true |
| 161 | +println("is BIC-11 : " + bic8.isBic11()); // false |
| 162 | +println("to BIC-11 : " + bic8.toBic11()); // MARKDEFFXXX |
| 163 | +``` |
| 164 | + |
| 165 | +#### 2\. Safe Parsing (returns Optional) |
| 166 | + |
| 167 | +```java |
| 168 | +import de.speedbanking.bic.Bic; |
| 169 | + |
| 170 | +Bic.tryParse("INVALIDBIC").ifPresentOrElse( |
| 171 | + bic -> System.out.println("Valid BIC: " + bic), |
| 172 | + () -> System.err.println("Invalid BIC") |
| 173 | +); |
| 174 | +``` |
| 175 | + |
| 176 | +----- |
| 177 | + |
| 178 | +## ⏱️ Performance |
| 179 | + |
| 180 | +*Note: Detailed JMH performance benchmarks comparing `iban-commons` with other popular Java libraries like `iban4j` are currently being finalized and will be included here soon.* |
| 181 | + |
| 182 | +We are committed to providing the fastest and most memory-efficient IBAN and BIC toolkit available, focusing on optimized string handling and minimal object allocation. Preliminary testing shows significant performance gains in validation throughput. |
| 183 | + |
| 184 | +----- |
| 185 | + |
| 186 | +## ⚖️ License |
| 187 | + |
| 188 | +This project is licensed under the **Apache License, Version 2.0**. You can find the full text of the license [here](https://www.apache.org/licenses/LICENSE-2.0). |
| 189 | + |
| 190 | +``` |
| 191 | +Copyright © 2025 Markus Spann, SpeedBanking |
| 192 | +
|
| 193 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 194 | +you may not use this file except in compliance with the License. |
| 195 | +You may obtain a copy of the License at |
| 196 | +
|
| 197 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 198 | +
|
| 199 | +Unless required by applicable law or agreed to in writing, software |
| 200 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 201 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 202 | +See the License for the specific language governing permissions and |
| 203 | +limitations under the License. |
| 204 | +``` |
| 205 | + |
| 206 | +----- |
0 commit comments