1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.oaipmh;
21
22 import eu.ehri.project.models.DocumentaryUnit;
23
24 import java.util.Optional;
25
26 class OaiPmhRecordResult {
27
28 private final DocumentaryUnit doc;
29 private final OaiPmhDeleted deleted;
30
31 private OaiPmhRecordResult(OaiPmhDeleted deleted, DocumentaryUnit doc) {
32 this.doc = doc;
33 this.deleted = deleted;
34 }
35
36 static OaiPmhRecordResult of(DocumentaryUnit doc) {
37 return new OaiPmhRecordResult(null, doc);
38 }
39
40 static OaiPmhRecordResult deleted(OaiPmhDeleted deleted) {
41 return new OaiPmhRecordResult(deleted, null);
42 }
43
44 static OaiPmhRecordResult invalid() {
45 return new OaiPmhRecordResult(null, null);
46 }
47
48 Optional<DocumentaryUnit> doc() {
49 return Optional.ofNullable(doc);
50 }
51
52 Optional<OaiPmhDeleted> deleted() {
53 return Optional.ofNullable(deleted);
54 }
55
56 boolean isInvalid() {
57 return deleted == null && doc == null;
58 }
59 }