1
1
package edu .harvard .iq .dataverse .harvest .client ;
2
2
3
+ import com .fasterxml .jackson .annotation .JsonCreator ;
4
+ import io .vavr .control .Option ;
5
+
6
+ import java .util .Collections ;
3
7
import java .util .List ;
4
- import java .util .stream .Collectors ;
5
8
6
9
/**
7
10
* Parameters used by the datacite DOI harvester.
@@ -10,24 +13,18 @@ public class DataciteHarvesterParams extends HarvesterParams {
10
13
11
14
private final static String DOI_PART_SEPARATOR = "/" ;
12
15
13
- private final List <DOIValue > doiImport ;
14
-
15
- // -------------------- CONSTRUCTORS --------------------
16
-
17
- public DataciteHarvesterParams (List <DOIValue > doi ) {
18
- this .doiImport = doi ;
19
- }
16
+ private List <DOIValue > doiImport ;
20
17
21
18
// -------------------- GETTERS --------------------
22
19
23
20
public List <DOIValue > getDoiImport () {
24
- return doiImport ;
21
+ return Option . of ( doiImport ). getOrElse ( Collections . emptyList ()) ;
25
22
}
26
23
27
- // -------------------- LOGIC --------------------
24
+ // -------------------- SETTERS --------------------
28
25
29
- public static DataciteHarvesterParams fromFullDOIList (List <String > fullDOI ) {
30
- return new DataciteHarvesterParams ( fullDOI . stream (). map ( DOIValue :: parseFullDOI ). collect ( Collectors . toList ())) ;
26
+ public void setDoiImport (List <DOIValue > doiImport ) {
27
+ this . doiImport = doiImport ;
31
28
}
32
29
33
30
// -------------------- INNER CLASSES --------------------
@@ -43,6 +40,15 @@ public DOIValue(String authority, String id) {
43
40
this .id = id ;
44
41
}
45
42
43
+ public DOIValue (String fullDoi ) {
44
+ String [] doiParts = fullDoi .split (DOI_PART_SEPARATOR );
45
+ if (doiParts .length != 2 ) {
46
+ throw new IllegalArgumentException ("Invalid DOI: " + fullDoi );
47
+ }
48
+ this .authority = doiParts [0 ];
49
+ this .id = doiParts [1 ];
50
+ }
51
+
46
52
// -------------------- GETTERS --------------------
47
53
48
54
public String getAuthority () {
@@ -56,16 +62,5 @@ public String getId() {
56
62
public String getFull () {
57
63
return authority + DOI_PART_SEPARATOR + id ;
58
64
}
59
-
60
- // -------------------- LOGIC --------------------
61
-
62
- public static DOIValue parseFullDOI (String fullDOI ) {
63
- String [] doiParts = fullDOI .split (DOI_PART_SEPARATOR );
64
- if (doiParts .length != 2 ) {
65
- throw new IllegalArgumentException ("Invalid DOI: " + fullDOI );
66
- }
67
- return new DOIValue (doiParts [0 ], doiParts [1 ]);
68
- }
69
-
70
65
}
71
66
}
0 commit comments