Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 152 #154

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 64 additions & 49 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,55 +54,6 @@
</developer>
</developers>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>8</maven.compiler.release>
<jdk7Signature>java17</jdk7Signature>
<skipSigning>true</skipSigning>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>junit-jupiter-params</artifactId>
<groupId>org.junit.jupiter</groupId>
<scope>test</scope>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
<version>0.7.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<build>
<plugins>

Expand All @@ -116,6 +67,8 @@
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}}</target>
</configuration>
</plugin>

Expand Down Expand Up @@ -281,9 +234,71 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.iban4j</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>

</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>junit-jupiter-params</artifactId>
<groupId>org.junit.jupiter</groupId>
<scope>test</scope>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
<version>0.7.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<jdk7Signature>java17</jdk7Signature>
<skipSigning>true</skipSigning>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
</properties>

<reporting>
<plugins>

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module org.iban4j {
exports org.iban4j;

opens org.iban4j;
}
20 changes: 20 additions & 0 deletions src/main/java/org/iban4j/Iban.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public final static class Builder {

private CountryCode countryCode;
private String bankCode;
private String bankCodeExt;
private String branchCode;
private String nationalCheckDigit;
private String accountType;
Expand Down Expand Up @@ -272,6 +273,17 @@ public Builder bankCode(final String bankCode) {
return this;
}

/**
* Sets iban's bank code extension.
*
* @param bankCodeExt String
* @return builder Builder
*/
public Builder bankCodeExt(final String bankCodeExt) {
this.bankCodeExt = bankCodeExt;
return this;
}

/**
* Sets iban's branch code.
*
Expand Down Expand Up @@ -444,6 +456,9 @@ private String formatBban() {
case bank_code:
sb.append(getPaddedString(bankCode, entry.getLength()));
break;
case bank_code_ext:
sb.append(getPaddedString(bankCodeExt, entry.getLength()));
break;
case branch_code:
sb.append(getPaddedString(branchCode, entry.getLength()));
break;
Expand Down Expand Up @@ -532,6 +547,11 @@ private void fillMissingFieldsRandomly(final Random random) {
bankCode = entry.getRandom(random);
}
break;
case bank_code_ext:
if (bankCodeExt == null) {
bankCodeExt = entry.getRandom(random);
}
break;
case branch_code:
if (branchCode == null) {
branchCode = entry.getRandom(random);
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/org/iban4j/IbanUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
*/
package org.iban4j;

import static org.iban4j.IbanFormatException.IbanFormatViolation.*;

import org.iban4j.bban.BbanEntryType;
import org.iban4j.bban.BbanStructure;
import org.iban4j.bban.BbanStructureEntry;

import static org.iban4j.IbanFormatException.IbanFormatViolation.*;
/**
* Iban Utility Class
*/
Expand Down Expand Up @@ -229,6 +230,16 @@ public static String getBankCode(final String iban) {
return extractBbanEntry(iban, BbanEntryType.bank_code);
}

/**
* Returns iban's bank code extension.
*
* @param iban String
* @return bankCodeExt String
*/
public static String getBankCodeExt(final String iban) {
return extractBbanEntry(iban, BbanEntryType.bank_code_ext);
}

/**
* Returns iban's branch code.
*
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/iban4j/bban/BbanEntryType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
public enum BbanEntryType {
bank_code,
bank_code_ext,
branch_code,
account_number,
national_check_digit,
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/iban4j/bban/BbanStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ public class BbanStructure {
CountryCode.SC,
new BbanStructure(
BbanStructureEntry.bankCode(4, 'a'),
BbanStructureEntry.branchCode(4, 'n'),
BbanStructureEntry.bankCodeExt(2, 'n'),
BbanStructureEntry.branchCode(2, 'n'),
BbanStructureEntry.accountNumber(16, 'n'),
BbanStructureEntry.accountType(3, 'a')));

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/iban4j/bban/BbanStructureEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public static BbanStructureEntry bankCode(final int length, final char character
EntryCharacterType.valueOf(String.valueOf(characterType)), length);
}

public static BbanStructureEntry bankCodeExt(final int length, final char characterType) {
return new BbanStructureEntry(
BbanEntryType.bank_code_ext,
EntryCharacterType.valueOf(String.valueOf(characterType)),
length);
}

public static BbanStructureEntry branchCode(final int length, final char characterType) {
return new BbanStructureEntry(BbanEntryType.branch_code,
EntryCharacterType.valueOf(String.valueOf(characterType)), length);
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/org/iban4j/TestDataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,12 @@ public static Collection<Object[]> getIbanData() {
},
{
new Iban.Builder()
.countryCode(CountryCode.MZ)
.bankCode("0003")
.branchCode("0108")
.accountNumber("00163671023")
.nationalCheckDigit("71")
.build(),
.countryCode(CountryCode.MZ)
.bankCode("0003")
.branchCode("0108")
.accountNumber("00163671023")
.nationalCheckDigit("71")
.build(),
"MZ59000301080016367102371"
},
{
Expand Down Expand Up @@ -633,7 +633,8 @@ public static Collection<Object[]> getIbanData() {
new Iban.Builder()
.countryCode(CountryCode.SC)
.bankCode("SSCB")
.branchCode("1101")
.bankCodeExt("11")
.branchCode("01")
.accountNumber("0000000000001497")
.accountType("USD")
.build(),
Expand Down
Loading