public class SwedishIdNumber extends LocalIdNumber
-
sign: For people under the age of 100ß
sign: For people that have reached the age of 100The remaining digits of the personnummer can interpreted differently:
Modifier and Type | Field and Description |
---|---|
static String |
SE_COUNTRY
A default country token for Sweden.
|
static Locale |
SWEDEN
A default Swedish locale.
|
static String |
VALID_FORMAT_SE
A regular expression for checking if a number is in the format of a Swedish ID number.
|
Constructor and Description |
---|
SwedishIdNumber(String idToken)
Creates a Swedish ID with default locale.
|
SwedishIdNumber(String idToken,
Locale locale)
Creates a new Swedish ID with the given locale.
|
Modifier and Type | Method and Description |
---|---|
Optional<LocalDate> |
birthday()
Determines the birth day of the person associated to this ID number, if applicable.
|
static Optional<LocalDate> |
birthday(IdNumber idNumber)
Calculates the birth date of the given IdNumber
|
static SwedishIdNumber |
forId(String token)
Provide an instance of IdNumber with Swedish locale and provides
implementation of all the method supported.
|
static SwedishIdNumber |
forId(String token,
Locale locale)
Provide an instance of IdNumber with Swedish locale and provides
implementation of all the method supported.
|
Optional<Gender> |
gender()
Determines the gender of the person that holds this ID number, if applicable.
|
static Optional<Gender> |
gender(IdNumber idNumber)
Extracts the gender from the given person number following the
specification for the Swedish idNumber
|
boolean |
isValid()
Checks if the given instance represents a valid Swedish ID number.
|
boolean |
supports(Locale locale)
Defines support method for given locale.
|
static boolean |
valid(IdNumber idNumber)
Standard implementation of validity check for Swedish idNumbers.
|
public static final String SE_COUNTRY
public static final Locale SWEDEN
public static final String VALID_FORMAT_SE
public SwedishIdNumber(String idToken, Locale locale)
idToken
- The ID token to represent.locale
- The Locale for the current instance of SwedishIdNumberpublic SwedishIdNumber(String idToken)
idToken
- The ID token to represent.public boolean supports(Locale locale)
LocalIdNumber
supports
in class LocalIdNumber
locale
- given locale.public static SwedishIdNumber forId(String token)
token
- The idTokenpublic static SwedishIdNumber forId(String token, Locale locale)
token
- the idTokenlocale
- The Locale for the current instance of SwedishIdNumberpublic static boolean valid(IdNumber idNumber)
idNumber
- The IdNumber to validatepublic boolean isValid()
true
if this instance represents a valid Swedish ID number.public static Optional<Gender> gender(IdNumber idNumber)
idNumber
- The IdNumber to considerpublic Optional<Gender> gender()
public static Optional<LocalDate> birthday(IdNumber idNumber)
idNumber
- The IdNumber to consider