org.iban4j.CountryCode Java Examples
The following examples show how to use
org.iban4j.CountryCode.
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 |
/** * 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: IBANProperties.java From jfairy with Apache License 2.0 | 5 votes |
private static String countryFromLanguage(String lang) { return COUNTRIES.entrySet().stream() .filter(locale -> locale.getKey().name().equals(lang)) .map(Map.Entry::getValue) .map(CountryCode::getAlpha2) .findFirst() .orElse("PL"); }
Example #3
Source File: TppController.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
@Override public ResponseEntity<String> getRandomTppId(String countryCode) { BankCodeStructure structure = new BankCodeStructure(CountryCode.getByCode(countryCode)); BbanStructure bbanStructure = new BbanStructure(); bbanStructure.setCountryPrefix(structure.getCountryCode().name()); bbanStructure.setLength(structure.getLength()); bbanStructure.setEntryType(BbanStructure.EntryType.valueOf(structure.getType().name().toUpperCase())); return dataRestClient.branchId(bbanStructure); }
Example #4
Source File: DefaultIBANProvider.java From jfairy with Apache License 2.0 | 5 votes |
@Override public void fillCountryCode() { if (countryCode == null) { List<Country> countries = Country.findCountryForLanguage(dataMaster.getLanguage()); Country country = baseProducer.randomElement(countries); countryCode = CountryCode.valueOf(country.getCode()); } }
Example #5
Source File: IbanBenchmark.java From iban4j with Apache License 2.0 | 5 votes |
@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(); } }
Example #6
Source File: IbanGenerationService.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
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 #7
Source File: TppControllerTest.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
@Test void getSupportedCountryCodes() { // Given when(ibanGenerationService.getCountryCodes()).thenReturn(getSuppCountryCodes()); // When ResponseEntity<Map<CountryCode, String>> response = tppController.getSupportedCountryCodes(); // Then assertTrue(response.getStatusCode().is2xxSuccessful()); assertEquals(Objects.requireNonNull(response.getBody()).size(), COUNTRY_CODES.size()); }
Example #8
Source File: BankDetailsServiceImpl.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
public void validateIban(String iban) throws IbanFormatException, InvalidCheckDigitException, UnsupportedCountryException { CountryCode countryCode = CountryCode.getByCode(IbanUtil.getCountryCode(iban)); if (countryCode == null) { throw new UnsupportedCountryException("Country code is not supported."); } if (IbanUtil.isSupportedCountry(countryCode)) { IbanUtil.validate(iban); } }
Example #9
Source File: IbanGenerationServiceTest.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
@Test void getCountryCodes() { // When Map<CountryCode, String> codes = generationService.getCountryCodes(); // Then assertFalse(codes.isEmpty()); }
Example #10
Source File: BankCodeStructure.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
public BankCodeStructure(CountryCode countryCode) { this.countryCode = countryCode; BbanStructure structure = Optional.ofNullable(BbanStructure.forCountry(countryCode)) .orElseThrow(() -> new IllegalArgumentException("Country code not supported!")); this.length = structure.getEntries().stream() .filter(e -> e.getEntryType().equals(bank_code)) .findFirst() .map(BbanStructureEntry::getLength) .orElse(0); this.type = structure.getEntries().stream() .filter(e -> e.getEntryType() == bank_code) .findFirst() .map(BbanStructureEntry::getCharacterType).orElseThrow(() -> new IllegalArgumentException("Can't define character type")); }
Example #11
Source File: TppControllerTest.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
private Map<CountryCode, String> getSuppCountryCodes() { Map<CountryCode, String> codes = new HashMap<>(); COUNTRY_CODES.forEach(c -> codes.put(c, c.getName())); return codes; }
Example #12
Source File: DefaultIBANProvider.java From jfairy with Apache License 2.0 | 4 votes |
@Override public void setCountry(String country) { this.countryCode = CountryCode.valueOf(country); }
Example #13
Source File: BbanStructure.java From iban4j with Apache License 2.0 | 4 votes |
public static List<CountryCode> supportedCountries() { final List<CountryCode> countryCodes = new ArrayList<CountryCode>(structures.size()); countryCodes.addAll(structures.keySet()); return Collections.unmodifiableList(countryCodes); }
Example #14
Source File: TppRestApi.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
@ApiOperation(value = "Get country codes") @GetMapping("/codes") ResponseEntity<Map<CountryCode, String>> getSupportedCountryCodes();
Example #15
Source File: TppController.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
@Override public ResponseEntity<Map<CountryCode, String>> getSupportedCountryCodes() { return ResponseEntity.ok(ibanGenerationService.getCountryCodes()); }
Example #16
Source File: TppControllerTest.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
private BankCodeStructure getBankCode() { return new BankCodeStructure(CountryCode.DE); }
Example #17
Source File: IbanGenerationService.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
public BankCodeStructure getBankCodeStructure(CountryCode code) { return new BankCodeStructure(code); }
Example #18
Source File: IbanGenerationService.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
public Map<CountryCode, String> getCountryCodes() { Map<CountryCode, String> codes = new HashMap<>(); COUNTRY_CODES.forEach(c -> codes.put(c, c.getName())); return TppData.sortMapByValue(codes); }
Example #19
Source File: TppData.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
public static Map<CountryCode, String> sortMapByValue(Map<CountryCode, String> map) { return map.entrySet() .stream() .sorted((Map.Entry.comparingByValue())) //NOPMD //each time different pmd violation .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); }
Example #20
Source File: TppController.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
@Override public ResponseEntity<BankCodeStructure> getBankCodeStructure(String countryCode) { return ResponseEntity.ok(ibanGenerationService.getBankCodeStructure(CountryCode.valueOf(countryCode))); }
Example #21
Source File: BbanStructure.java From iban4j with Apache License 2.0 | 2 votes |
/** * @param countryCode the country code. * @return BbanStructure for specified country or null if country is not supported. */ public static BbanStructure forCountry(final CountryCode countryCode) { return structures.get(countryCode); }