|
10 | 10 | public class DataProvider { |
11 | 11 | private static final List<PersonnummerData> all = new ArrayList<>(); |
12 | 12 | private static final List<PersonnummerData> orgNr = new ArrayList<>(); |
| 13 | + private static final List<PersonnummerData> interimNr = new ArrayList<>(); |
13 | 14 |
|
14 | 15 | public static void initialize() throws IOException { |
15 | 16 | InputStream in = new URL("https://raw.githubusercontent.com/personnummer/meta/master/testdata/list.json").openStream(); |
@@ -55,8 +56,38 @@ public static void initialize() throws IOException { |
55 | 56 | current.getString("type") |
56 | 57 | )); |
57 | 58 | } |
| 59 | + |
| 60 | + |
| 61 | + in = new URL("https://raw.githubusercontent.com/personnummer/meta/master/testdata/interim.json").openStream(); |
| 62 | + reader = new BufferedReader(new InputStreamReader(in)); |
| 63 | + json = ""; |
| 64 | + while ((line = reader.readLine()) != null) { |
| 65 | + json = json.concat(line); |
| 66 | + } |
| 67 | + |
| 68 | + in.close(); |
| 69 | + rootObject = new JSONArray(json); |
| 70 | + for (int i = 0; i < rootObject.length(); i++) { |
| 71 | + JSONObject current = rootObject.getJSONObject(i); |
| 72 | + interimNr.add(new PersonnummerData( |
| 73 | + current.getLong("integer"), |
| 74 | + current.getString("short_format"), |
| 75 | + current.getString("separated_format"), |
| 76 | + current.getBoolean("valid"), |
| 77 | + current.getString("type") |
| 78 | + )); |
| 79 | + } |
58 | 80 | } |
59 | 81 |
|
| 82 | + public static List<PersonnummerData> getInterimNumbers() { |
| 83 | + return interimNr; |
| 84 | + } |
| 85 | + public static List<PersonnummerData> getValidInterimNumbers() { |
| 86 | + return interimNr.stream().filter(o -> o.valid).collect(Collectors.toList()); |
| 87 | + } |
| 88 | + public static List<PersonnummerData> getInvalidInterimNumbers() { |
| 89 | + return interimNr.stream().filter(o -> !o.valid).collect(Collectors.toList()); |
| 90 | + } |
60 | 91 | public static List<PersonnummerData> getCoordinationNumbers() { |
61 | 92 | return all.stream().filter(o -> !o.type.equals("ssn")).collect(Collectors.toList()); |
62 | 93 | } |
|
0 commit comments