Skip to content

Commit 6b2797f

Browse files
committed
Review nullability declaration on XPathExpression and XPathOperations
Closes gh-1727
1 parent 9d7d43c commit 6b2797f

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathExpressionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ public List<Node> evaluateAsNodeList(Node node) {
171171
}
172172

173173
@Override
174-
public <T> List<T> evaluate(Node context, NodeMapper<T> nodeMapper) throws XPathException {
174+
public <T> List<@Nullable T> evaluate(Node context, NodeMapper<T> nodeMapper) throws XPathException {
175175
try {
176176
List<?> nodes = this.xpath.selectNodes(context);
177-
List<T> results = new ArrayList<>(nodes.size());
177+
List<@Nullable T> results = new ArrayList<>(nodes.size());
178178
for (int i = 0; i < nodes.size(); i++) {
179179
Node node = (Node) nodes.get(i);
180180
try {

spring-xml/src/main/java/org/springframework/xml/xpath/JaxenXPathTemplate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ public String evaluateAsString(String expression, Source context) throws XPathEx
148148
}
149149

150150
@Override
151-
public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
151+
public <T> List<@Nullable T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper)
152+
throws XPathException {
152153
try {
153154
XPath xpath = createXPath(expression);
154155
Element element = getRootElement(context);
155156
List<?> nodes = xpath.selectNodes(element);
156-
List<T> results = new ArrayList<>(nodes.size());
157+
List<@Nullable T> results = new ArrayList<>(nodes.size());
157158
for (int i = 0; i < nodes.size(); i++) {
158159
Node node = (Node) nodes.get(i);
159160
try {

spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathExpressionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ public Node evaluateAsNode(Node node) {
165165
}
166166

167167
@Override
168-
public <T> List<T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException {
168+
public <T> List<@Nullable T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException {
169169
NodeList nodes = (NodeList) evaluate(node, XPathConstants.NODESET);
170-
List<T> results = new ArrayList<>(nodes.getLength());
170+
List<@Nullable T> results = new ArrayList<>(nodes.getLength());
171171
for (int i = 0; i < nodes.getLength(); i++) {
172172
try {
173173
results.add(nodeMapper.mapNode(nodes.item(i), i));

spring-xml/src/main/java/org/springframework/xml/xpath/Jaxp13XPathTemplate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ public double evaluateAsDouble(String expression, Source context) throws XPathEx
123123
}
124124

125125
@Override
126-
public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
126+
public <T> List<@Nullable T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper)
127+
throws XPathException {
127128
NodeList nodes = (NodeList) evaluate(expression, context, XPathConstants.NODESET);
128-
List<T> results = new ArrayList<>();
129+
List<@Nullable T> results = new ArrayList<>();
129130
if (nodes != null) {
130131
for (int i = 0; i < nodes.getLength(); i++) {
131132
try {

spring-xml/src/main/java/org/springframework/xml/xpath/XPathExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ public interface XPathExpression {
121121
* @throws XPathException in case of XPath errors
122122
* @see <a href="http://www.w3.org/TR/xpath#node-sets">XPath specification</a>
123123
*/
124-
<T> List<T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException;
124+
<T> List<@Nullable T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException;
125125

126126
}

spring-xml/src/main/java/org/springframework/xml/xpath/XPathOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public interface XPathOperations {
133133
* @throws XPathException in case of XPath errors
134134
* @see <a href="http://www.w3.org/TR/xpath#node-sets">XPath specification</a>
135135
*/
136-
<T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException;
136+
<T> List<@Nullable T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException;
137137

138138
/**
139139
* Evaluates the given expression, handling the result {@link Node} objects on a

0 commit comments

Comments
 (0)