Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit afe0c7e

Browse files
committed
fixed NPE in holdings copy constructor
1 parent 801a893 commit afe0c7e

2 files changed

Lines changed: 16 additions & 25 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.cdlib</groupId>
66
<artifactId>d2d-commons</artifactId>
77
<packaging>jar</packaging>
8-
<version>1.6.1</version>
8+
<version>1.6.2</version>
99
<name>D2D Commons</name>
1010

1111
<!-- comment -->

src/main/java/org/cdlib/domain/objects/holdings/Holdings.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
import org.cdlib.util.JSON;
1212

1313
/**
14-
* Summarized list of lending candidates, as Items, and the Bib for which they
15-
* are relevant.
14+
* Summarized list of lending candidates, as Items, and the Bib for which they are relevant.
1615
*
17-
* The meaning of Bib is the Bib requested for which relevant holdings are gathered;
18-
* the actual held items may reference a different Bib record (hence the individual items
19-
* have OCLC numbers that differ from the Bib), because the provider of the Holdings
20-
* may determine that these other items are close enough to fulfill the request.
16+
* The meaning of Bib is the Bib requested for which relevant holdings are gathered; the actual held
17+
* items may reference a different Bib record (hence the individual items have OCLC numbers that
18+
* differ from the Bib), because the provider of the Holdings may determine that these other items
19+
* are close enough to fulfill the request.
2120
*
2221
* The heldItems and linksToContent collections are guaranteed not to be null.
2322
*/
@@ -30,17 +29,16 @@ public class Holdings {
3029
@Valid
3130
@NotNull(message = "A list of holdings is required.")
3231
private List<Item> heldItems;
33-
32+
3433
/*
35-
* links to online resources that could fulfill
36-
* a request for this Bib
34+
* links to online resources that could fulfill a request for this Bib
3735
*/
3836
@Valid
3937
@NotNull
4038
private List<Link> linksToContent;
41-
39+
4240
@Valid
43-
@NotNull(message = "Resource metadata is requird.")
41+
@NotNull(message = "Resource metadata is required.")
4442
private ResourceMeta resourceMeta;
4543

4644
public Holdings() {
@@ -50,19 +48,12 @@ public Holdings() {
5048
}
5149

5250
public Holdings(Holdings source) {
51+
this();
5352
if (source.bib != null) {
5453
this.bib = new Bib(source.bib);
5554
}
56-
if (source.heldItems != null) {
57-
this.heldItems.addAll(source.heldItems);
58-
} else {
59-
heldItems = new ArrayList<>();
60-
}
61-
if (source.linksToContent != null) {
62-
this.linksToContent.addAll(source.linksToContent);
63-
} else {
64-
linksToContent = new ArrayList<>();
65-
}
55+
this.heldItems.addAll(source.heldItems);
56+
this.linksToContent.addAll(source.linksToContent);
6657
}
6758

6859
public Holdings(Bib bib, List<Item> heldItems, ResourceMeta resourceMeta) {
@@ -121,9 +112,9 @@ public boolean equals(Object obj) {
121112
return false;
122113
}
123114
Holdings other = (Holdings) obj;
124-
return Objects.equals(bib, other.bib)
125-
&& Objects.equals(heldItems, other.heldItems)
126-
&& Objects.equals(linksToContent, other.linksToContent)
115+
return Objects.equals(bib, other.bib)
116+
&& Objects.equals(heldItems, other.heldItems)
117+
&& Objects.equals(linksToContent, other.linksToContent)
127118
&& Objects.equals(resourceMeta, other.resourceMeta);
128119
}
129120

0 commit comments

Comments
 (0)