File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed
src/main/java/org/apache/commons/jxpath Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change 2020import java .util .ArrayList ;
2121import java .util .Collections ;
2222import java .util .List ;
23+ import java .util .stream .Collectors ;
2324
2425/**
2526 * A simple implementation of {@link NodeSet} that behaves as a collection of pointers.
@@ -65,12 +66,7 @@ private synchronized void clear() {
6566 @ Override
6667 public synchronized List getNodes () {
6768 if (nodes == null ) {
68- nodes = new ArrayList <>();
69- for (int i = 0 ; i < pointers .size (); i ++) {
70- final Pointer pointer = pointers .get (i );
71- nodes .add (pointer .getNode ());
72- }
73- nodes = Collections .unmodifiableList (nodes );
69+ nodes = Collections .unmodifiableList (pointers .stream ().map (Pointer ::getNode ).collect (Collectors .toList ()));
7470 }
7571 return nodes ;
7672 }
@@ -86,12 +82,7 @@ public synchronized List<Pointer> getPointers() {
8682 @ Override
8783 public synchronized List getValues () {
8884 if (values == null ) {
89- values = new ArrayList <>();
90- for (int i = 0 ; i < pointers .size (); i ++) {
91- final Pointer pointer = pointers .get (i );
92- values .add (pointer .getValue ());
93- }
94- values = Collections .unmodifiableList (values );
85+ values = Collections .unmodifiableList (pointers .stream ().map (Pointer ::getValue ).collect (Collectors .toList ()));
9586 }
9687 return values ;
9788 }
You can’t perform that action at this time.
0 commit comments