|
| 1 | +# SpeedBanking IBAN Commons - Welcome |
| 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 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 | +### Java Version |
| 54 | + |
| 55 | +This project is compiled and tested for **Java 8** compatibility to ensure maximum reach, while still supporting newer versions. |
| 56 | + |
| 57 | +----- |
| 58 | + |
| 59 | +## 💡 Code Examples |
| 60 | + |
| 61 | +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`. |
| 62 | + |
| 63 | +### IBAN |
| 64 | + |
| 65 | +The `Iban` class implements `CharSequence`, `Comparable<Iban>`, and `Serializable`. |
| 66 | + |
| 67 | +#### 1\. Quick Validation (throws exception on failure) |
| 68 | + |
| 69 | +Use `Iban.of()` when you expect the input to be valid and prefer an exception for validation failures. |
| 70 | + |
| 71 | +```java |
| 72 | +import de.speedbanking.iban.Iban; |
| 73 | +import de.speedbanking.iban.InvalidIbanException; |
| 74 | + |
| 75 | +String unformattedIban = "DE91 1000 0000 0123 4567 89"; |
| 76 | + |
| 77 | +try { |
| 78 | + Iban iban = Iban.of(unformattedIban); |
| 79 | + |
| 80 | + // get components |
| 81 | + System.out.println("Country Code: " + iban.getCountryCode()); // DE |
| 82 | + System.out.println("Check Digits: " + iban.getCheckDigits()); // 91 |
| 83 | + System.out.println("BBAN: " + iban.getBban()); // 100000000123456789 |
| 84 | + System.out.println("Bank Code: " + iban.getBankCode()); // 10000000 |
| 85 | + System.out.println("Account Number: " + iban.getAccountNumber()); // 0123456789 |
| 86 | + |
| 87 | + // formatting |
| 88 | + System.out.println("Formatted: " + iban.toFormattedString()); // DE91 1000 0000 0123 4567 89 |
| 89 | + System.out.println("Normalized: " + iban.toString()); // DE91100000000123456789 |
| 90 | + |
| 91 | +} catch (InvalidIbanException ex) { |
| 92 | + System.err.println("IBAN validation failed: " + ex.getMessage()); |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +#### 2\. Safe Parsing (returns Optional) |
| 97 | + |
| 98 | +Use `Iban.tryParse()` when dealing with external or uncertain input, avoiding exceptions for control flow. |
| 99 | + |
| 100 | +```java |
| 101 | +import de.speedbanking.iban.Iban; |
| 102 | +import java.util.Optional; |
| 103 | + |
| 104 | +String potentialIban = "GB29 NWBK 6016 1331 9268 19"; |
| 105 | + |
| 106 | +Optional<Iban> optionalIban = Iban.tryParse(potentialIban); |
| 107 | + |
| 108 | +optionalIban.ifPresent(iban -> { |
| 109 | + System.out.println("Country Name: " + iban.getCountryName()); // United Kingdom |
| 110 | +}); |
| 111 | +``` |
| 112 | + |
| 113 | +----- |
| 114 | + |
| 115 | +### BIC |
| 116 | + |
| 117 | +The `Bic` class implements `CharSequence`, `Comparable<Bic>`, and `Serializable`. A BIC comparison is always based on the 11-character representation (`toBic11()`), meaning **BIC-8 and its BIC-11 equivalent are considered equal**. |
| 118 | + |
| 119 | +#### 1\. Quick Validation (throws exception on failure) |
| 120 | + |
| 121 | +```java |
| 122 | +import de.speedbanking.bic.Bic; |
| 123 | + |
| 124 | +Bic bic11 = Bic.of("DEUTDEFF500"); |
| 125 | + |
| 126 | +System.out.println("Bank Code: " + bic11.getBankCode()); // DEUT |
| 127 | +System.out.println("Country Code: " + bic11.getCountryCode()); // DE |
| 128 | +System.out.println("Location Code: " + bic11.getLocationCode()); // FF |
| 129 | +System.out.println("Branch Code: " + bic11.getBranchCode()); // 500 |
| 130 | +System.out.println("Is BIC-8: " + bic11.isBic8()); // false |
| 131 | +System.out.println("To BIC-8: " + bic11.toBic8()); // DEUTDEFF |
| 132 | + |
| 133 | +// BIC-8 |
| 134 | +Bic bic8 = Bic.of("MARKDEFF"); |
| 135 | +System.out.println("Branch Code: " + bic8.getBranchCode()); // null |
| 136 | +System.out.println("To BIC-11: " + bic8.toBic11()); // MARKDEFFXXX |
| 137 | +``` |
| 138 | + |
| 139 | +#### 2\. Safe Parsing (Returns Optional) |
| 140 | + |
| 141 | +```java |
| 142 | +import de.speedbanking.bic.Bic; |
| 143 | + |
| 144 | +Bic.tryParse("INVALIDBIC").ifPresentOrElse( |
| 145 | + bic -> System.out.println("Valid BIC: " + bic), |
| 146 | + () -> System.out.println("Invalid BIC") |
| 147 | +); |
| 148 | +``` |
| 149 | + |
| 150 | +----- |
| 151 | + |
| 152 | +## ⏱️ Performance |
| 153 | + |
| 154 | +*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.* |
| 155 | + |
| 156 | +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. |
| 157 | + |
| 158 | +----- |
| 159 | + |
| 160 | +## ⚖️ License |
| 161 | + |
| 162 | +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). |
| 163 | + |
| 164 | +``` |
| 165 | +Copyright © 2025 SpeedBanking |
| 166 | +
|
| 167 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 168 | +you may not use this file except in compliance with the License. |
| 169 | +You may obtain a copy of the License at |
| 170 | +
|
| 171 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 172 | +
|
| 173 | +Unless required by applicable law or agreed to in writing, software |
| 174 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 175 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 176 | +See the License for the specific language governing permissions and |
| 177 | +limitations under the License. |
| 178 | +``` |
| 179 | + |
| 180 | +----- |
0 commit comments