Package fr.marcwrobel.jbanking.iban
Class RandomIban
java.lang.Object
fr.marcwrobel.jbanking.iban.RandomIban
Generates pseudorandom
IBANs.
Usage:
// Generating a random IBAN
Iban random1 = new RandomIban().next();
// Generating a random IBAN using a given Random (in order to make the generation deterministic)
Iban random2 = new RandomIban(new Random(0)).next();
// Generating a random french or german IBAN (with BbanStructure or IsoCountry)
Iban random3 = new RandomIban().next(BbanStructure.FR, BbanStructure.DE);
Iban random4 = new RandomIban().next(BbanStructure.valueOf(IsoCountry.FR.name()),
BbanStructure.valueOf(IsoCountry.DE.name()));
This class should be used only for tests.
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new random Iban generator.RandomIban(Random random) Creates a new random Iban generator using the givenrandom number generator. -
Method Summary
Modifier and TypeMethodDescriptionnext()Generates a random IBAN for one of the existingISO 13616-compliant national IBAN formats(randomly chosen).next(BbanStructure... structures) Generates a random IBAN for one of the givenISO 13616-compliant national IBAN formats(randomly chosen).
-
Constructor Details
-
RandomIban
Creates a new random Iban generator using the givenrandom number generator.- Parameters:
random- a non-nullRandominstance- Throws:
NullPointerException- if the givenRandominstance isnull
-
RandomIban
public RandomIban()Creates a new random Iban generator.This constructor is creating a new
random number generatoreach time it is invoked.
-
-
Method Details
-
next
Generates a random IBAN for one of the existingISO 13616-compliant national IBAN formats(randomly chosen).- Returns:
- a non-null
Iban
-
next
Generates a random IBAN for one of the givenISO 13616-compliant national IBAN formats(randomly chosen).- Parameters:
structures- a non-null and non-empty array ofBbanStructure- Returns:
- a non-null
Iban - Throws:
NullPointerException- if one of the givenBbanStructureisnullIllegalArgumentException- ifstructuresis empty
-