fi.kapsi.killnine.iban.spi.IbanValidationService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iban-validator Show documentation
Show all versions of iban-validator Show documentation
A Java library for IBAN validation
The newest version!
package fi.kapsi.killnine.iban.spi;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import fi.kapsi.killnine.iban.Iban;
/**
* A service for acquiring IBAN validations. Uses ServiceLoader
as a simple SPI mechanism.
*/
public class IbanValidationService {
private static final ServiceLoader VALIDATION_LOADER = ServiceLoader.load(IbanValidation.class);
/**
* Gets configured validations capable of validating the given IBAN.
*
* @param iban IBAN to validate.
*
* @return validations for validating the IBAN.
*/
public List getValidations(Iban iban) {
List validations = new ArrayList();
for (IbanValidation validation : VALIDATION_LOADER) {
if (validation.canValidate(iban)) {
validations.add(validation);
}
}
return validations;
}
}