org.iban4j.Iban Java Examples

The following examples show how to use org.iban4j.Iban. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TppData.java    From XS2A-Sandbox with Apache License 2.0 6 votes vote down vote up
/**
 * Empty list for Account Access is common situation for new Tpp user
 *
 * @param user Tpp user object
 */
public TppData(UserTO user) {
    if (user == null || StringUtils.isEmpty(user.getBranch()) || user.getAccountAccesses() == null) {
        throw new TppException("Could not retrieve tpp data", 400);
    }
    String[] countryCodeAndBranchId = user.getBranch().split("_");
    this.countryCode = CountryCode.valueOf(countryCodeAndBranchId[0]);
    this.branchId = countryCodeAndBranchId[1];
    this.nextAccountNumber = user.getAccountAccesses().stream()
                                 .map(AccountAccessTO::getIban)
                                 .map(Iban::valueOf)
                                 .map(Iban::getAccountNumber)
                                 .map(Long::parseLong)
                                 .max(Comparator.comparingLong(Long::longValue))
                                 .map(i -> ++i)
                                 .orElse(100L);
}
 
Example #2
Source File: IbanGenerationService.java    From XS2A-Sandbox with Apache License 2.0 5 votes vote down vote up
private String generateIban(CountryCode countryCode, String bankCode, long accountNr) {
    int accountNumberLength = BbanStructure.forCountry(countryCode).getEntries().stream()
                                  .filter(e -> e.getEntryType().equals(account_number))
                                  .findFirst()
                                  .map(BbanStructureEntry::getLength)
                                  .orElse(0);
    String formatParam = "%0" + accountNumberLength + "d";
    String accountNumber = String.format(formatParam, accountNr);
    return new Iban.Builder()
               .countryCode(countryCode)
               .bankCode(bankCode)
               .accountNumber(accountNumber)
               .buildRandom()
               .toString();
}
 
Example #3
Source File: IbanBenchmark.java    From iban4j with Apache License 2.0 5 votes vote down vote up
@BenchmarkOptions(benchmarkRounds = 3, warmupRounds = 1)
@Test
@Ignore
public void ibanConstruction() {

    for(int i = 0; i < LOOPS_COUNT; i++) {
        Iban iban = new Iban.Builder()
                        .countryCode(CountryCode.DE)
                        .bankCode("52060170")
                        .accountNumber("0012335785")
                        .build();
    }
}