|
| 1 | +Welcome to SpeedBanking IBAN Commons! |
| 2 | + |
| 3 | +**IBAN Commons is our ultra-fast, zero-dependency, 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 | + Keep your build clean and avoid dependency conflicts. |
| 24 | + |
| 25 | + * **High Performance:** |
| 26 | + Optimized for execution speed and low memory footprint. |
| 27 | + |
| 28 | + * **Simple API:** |
| 29 | + Intuitive factory methods (`Iban.of()`, `Bic.tryParse()`) and clear component accessors. |
| 30 | + |
| 31 | + * **Immutability:** |
| 32 | + Both `Iban` and `Bic` classes are immutable and thread-safe. |
| 33 | + |
| 34 | + * **Comprehensive:** |
| 35 | + Full support for IBAN and BIC validation according to ISO standards. |
| 36 | + |
| 37 | +----- |
| 38 | + |
| 39 | +## 🛠️ Usage |
| 40 | + |
| 41 | +### Maven Dependency |
| 42 | + |
| 43 | +Add the following to your project's `pom.xml`: |
| 44 | + |
| 45 | +```xml |
| 46 | +<dependency> |
| 47 | + <groupId>de.speedbanking</groupId> |
| 48 | + <artifactId>iban-commons</artifactId> |
| 49 | + <version>1.8.0</version> |
| 50 | +</dependency> |
| 51 | +``` |
| 52 | + |
| 53 | +### Gradle Dependency |
| 54 | + |
| 55 | +Add the following if your project builds with Gradle: |
| 56 | + |
| 57 | +``` |
| 58 | +implementation 'de.speedbanking:iban-commons:1.8.0' |
| 59 | +``` |
| 60 | + |
| 61 | +### Java Version |
| 62 | + |
| 63 | +This project is compiled and tested for **Java 8** compatibility to ensure maximum reach, while still supporting newer versions. |
| 64 | + |
| 65 | +----- |
| 66 | + |
| 67 | +## 💡 Code Examples |
| 68 | + |
| 69 | +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`. |
| 70 | + |
| 71 | +### IBAN |
| 72 | + |
| 73 | +The `Iban` class implements `Serializable`, `CharSequence`, and `Comparable<Iban>`. |
| 74 | + |
| 75 | +#### 1\. Quick Validation (throws exception on failure) |
| 76 | + |
| 77 | +Use `Iban.of()` when you expect the input to be valid and prefer an exception for validation failures. |
| 78 | + |
| 79 | +```java |
| 80 | +import de.speedbanking.iban.Iban; |
| 81 | +import de.speedbanking.iban.InvalidIbanException; |
| 82 | + |
| 83 | +String ibanInput = "DE91100000000123456789"; |
| 84 | + |
| 85 | +try { |
| 86 | + Iban iban = Iban.of(ibanInput); |
| 87 | + |
| 88 | + // getters |
| 89 | + println("Country Code: " + iban.getCountryCode()); // DE |
| 90 | + println("Check Digits: " + iban.getCheckDigits()); // 91 |
| 91 | + println("BBAN : " + iban.getBban()); // 100000000123456789 |
| 92 | + println("Bank Code : " + iban.getBankCode()); // 10000000 |
| 93 | + println("Account No : " + iban.getAccountNumber()); // 0123456789 |
| 94 | + |
| 95 | + // output |
| 96 | + println("Normalized : " + iban.toString()); // DE91100000000123456789 |
| 97 | + println("Formatted : " + iban.toFormattedString()); // DE91 1000 0000 0123 4567 89 |
| 98 | + |
| 99 | +} catch (InvalidIbanException ex) { |
| 100 | + println("IBAN validation failed: " + ex.getMessage()); |
| 101 | +} |
| 102 | + |
| 103 | +static void println(String x) { System.out.println(x); } |
| 104 | + |
| 105 | +``` |
| 106 | + |
| 107 | +#### 2\. Safe Parsing (returns Optional) |
| 108 | + |
| 109 | +Use `Iban.tryParse()` when dealing with external or uncertain input, avoiding exceptions for control flow. |
| 110 | + |
| 111 | +```java |
| 112 | +import de.speedbanking.iban.Iban; |
| 113 | +import java.util.Optional; |
| 114 | + |
| 115 | +Optional<Iban> optionalIban = Iban.tryParse("PS92PALS000000000400123456702"); |
| 116 | + |
| 117 | +optionalIban.ifPresent(iban -> { |
| 118 | + println("Country Code: " + iban.getCountryCode()); // PS |
| 119 | + println("Country Name: " + iban.getCountryName()); // State of Palestine |
| 120 | + println("Country Flag: " + iban.getCountryFlag()); // 🇵🇸 |
| 121 | + println("Organisation: " + iban.getOrganisation()); // Palestine Monetary Authority |
| 122 | +}); |
| 123 | +``` |
| 124 | + |
| 125 | +----- |
| 126 | + |
| 127 | +### BIC |
| 128 | + |
| 129 | +The `Bic` class implements `Serializable`, `CharSequence`, and `Comparable<Bic>`. |
| 130 | +A BIC comparison is always based on the 11-character representation (`toBic11()`), meaning BIC-8 and its BIC-11 equivalent are considered equal. |
| 131 | + |
| 132 | +#### 1\. Quick Validation (throws exception on failure) |
| 133 | + |
| 134 | +```java |
| 135 | +import de.speedbanking.bic.Bic; |
| 136 | + |
| 137 | +Bic bic11 = Bic.of("DEUTDEFF500"); |
| 138 | + |
| 139 | +println("Bank Code : " + bic11.getBankCode()); // DEUT |
| 140 | +println("Country Code : " + bic11.getCountryCode()); // DE |
| 141 | +println("Location Code: " + bic11.getLocationCode()); // FF |
| 142 | +println("Branch Code : " + bic11.getBranchCode()); // 500 |
| 143 | +println("Is BIC-11 : " + bic11.isBic11()); // true |
| 144 | +println("Is BIC-8 : " + bic11.isBic8()); // false |
| 145 | +println("To BIC-8 : " + bic11.toBic8()); // DEUTDEFF |
| 146 | + |
| 147 | +// BIC-8 |
| 148 | +Bic bic8 = Bic.of("MARKDEFF"); |
| 149 | +println("Is BIC-8 : " + bic8.isBic8()); // true |
| 150 | +println("Is BIC-11 : " + bic8.isBic11()); // false |
| 151 | +println("To BIC-11 : " + bic8.toBic11()); // MARKDEFFXXX |
| 152 | +``` |
| 153 | + |
| 154 | +#### 2\. Safe Parsing (returns Optional) |
| 155 | + |
| 156 | +```java |
| 157 | +import de.speedbanking.bic.Bic; |
| 158 | + |
| 159 | +Bic.tryParse("INVALIDBIC").ifPresentOrElse( |
| 160 | + bic -> System.out.println("Valid BIC: " + bic), |
| 161 | + () -> System.err.println("Invalid BIC") |
| 162 | +); |
| 163 | +``` |
| 164 | + |
| 165 | +----- |
| 166 | + |
| 167 | +## ⏱️ Performance |
| 168 | + |
| 169 | +*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.* |
| 170 | + |
| 171 | +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. |
| 172 | + |
| 173 | +----- |
| 174 | + |
| 175 | +## ⚖️ License |
| 176 | + |
| 177 | +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). |
| 178 | + |
| 179 | +``` |
| 180 | +Copyright © 2025 Markus Spann, SpeedBanking |
| 181 | +
|
| 182 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 183 | +you may not use this file except in compliance with the License. |
| 184 | +You may obtain a copy of the License at |
| 185 | +
|
| 186 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 187 | +
|
| 188 | +Unless required by applicable law or agreed to in writing, software |
| 189 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 190 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 191 | +See the License for the specific language governing permissions and |
| 192 | +limitations under the License. |
| 193 | +``` |
| 194 | + |
| 195 | +----- |
0 commit comments