forked from Devskiller/jfairy
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Devskiller#37 from Codearte/spanish
Spanish
- Loading branch information
Showing
10 changed files
with
264 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 18 additions & 13 deletions
31
src/main/java/io/codearte/jfairy/producer/company/locale/es/CIFProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
package io.codearte.jfairy.producer.company.locale.es; | ||
|
||
import io.codearte.jfairy.producer.VATIdentificationNumberProvider; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; | ||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; | ||
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; | ||
|
||
/** | ||
* @author graux | ||
* @since 26/04/2015 | ||
* Código de Identificación Fiscal (CIF) Español | ||
*/ | ||
public class CIFProvider implements VATIdentificationNumberProvider { | ||
|
||
private static final String REGEX_CIF = "^[A-Z][0-9]{2}[0-9]{5}([KPQSABEH]|[0-9]|[A-Z])$"; | ||
private Pattern regexCif; | ||
private static final String REGEX_CIF = "^[A-Z][0-9]{2}[0-9]{5}([KPQSABEH]|[0-9]|[A-Z])$"; | ||
|
||
private Pattern regexCif; | ||
|
||
public CIFProvider() { | ||
this.regexCif = Pattern.compile(REGEX_CIF); | ||
} | ||
public CIFProvider() { | ||
this.regexCif = Pattern.compile(REGEX_CIF); | ||
} | ||
|
||
@Override | ||
public String get() { | ||
return String.format("%s%s%s", RandomStringUtils.randomAlphabetic(1).toUpperCase(), RandomStringUtils.randomNumeric(7), RandomStringUtils.randomAlphanumeric(1).toUpperCase()); | ||
} | ||
@Override | ||
public String get() { | ||
return String.format("%s%s%s", | ||
randomAlphabetic(1).toUpperCase(), randomNumeric(7), randomAlphanumeric(1).toUpperCase()); | ||
} | ||
|
||
public boolean isValid(String cif) { | ||
return this.regexCif.matcher(cif).matches(); | ||
} | ||
public boolean isValid(String cif) { | ||
return this.regexCif.matcher(cif).matches(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.