Skip to content

Commit 0cdd3f6

Browse files
committed
Use generics internally
1 parent c7a4198 commit 0cdd3f6

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

src/main/java/org/apache/commons/jxpath/ri/model/NodePointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public int compareTo(final Object object) {
292292
// Task 1: find the common parent
293293
int depth1 = 0;
294294
NodePointer p1 = this;
295-
final HashSet parents1 = new HashSet();
295+
final HashSet<NodePointer> parents1 = new HashSet<>();
296296
while (p1 != null) {
297297
depth1++;
298298
p1 = p1.parent;

src/main/java/org/apache/commons/jxpath/ri/model/beans/CollectionNodeIterator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public abstract class CollectionNodeIterator implements NodeIterator {
3333
private final boolean reverse;
3434
private final NodePointer startWith;
3535
private int position;
36-
private List collection;
36+
private List<NodePointer> collection;
3737

3838
/**
3939
* Create a new CollectionNodeIterator.
@@ -73,7 +73,7 @@ public int getPosition() {
7373
* Prepare...
7474
*/
7575
private void prepare() {
76-
collection = new ArrayList();
76+
collection = new ArrayList<>();
7777
final NodePointer ptr = (NodePointer) pointer.clone();
7878
final int length = ptr.getLength();
7979
for (int i = 0; i < length; i++) {

src/main/java/org/apache/commons/jxpath/ri/model/dom/DOMNamespaceIterator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class DOMNamespaceIterator implements NodeIterator {
3434

3535
private final NodePointer parent;
36-
private final List attributes;
36+
private final List<Attr> attributes;
3737
private int position = 0;
3838

3939
/**
@@ -43,7 +43,7 @@ public class DOMNamespaceIterator implements NodeIterator {
4343
*/
4444
public DOMNamespaceIterator(final NodePointer parent) {
4545
this.parent = parent;
46-
attributes = new ArrayList();
46+
attributes = new ArrayList<>();
4747
collectNamespaces(attributes, (Node) parent.getNode());
4848
}
4949

@@ -53,7 +53,7 @@ public DOMNamespaceIterator(final NodePointer parent) {
5353
* @param attributes attribute list
5454
* @param node target node
5555
*/
56-
private void collectNamespaces(final List attributes, Node node) {
56+
private void collectNamespaces(final List<Attr> attributes, Node node) {
5757
final Node parent = node.getParentNode();
5858
if (parent != null) {
5959
collectNamespaces(attributes, parent);

src/main/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static boolean testNode(final Node node, final NodeTest test) {
208208
}
209209

210210
private final Node node;
211-
private Map namespaces;
211+
private Map<String, String> namespaces;
212212
private String defaultNamespace;
213213
private String id;
214214
private NamespaceResolver localNamespaceResolver;
@@ -508,9 +508,9 @@ public String getNamespaceURI(final String prefix) {
508508
}
509509
String namespace = null;
510510
if (namespaces == null) {
511-
namespaces = new HashMap();
511+
namespaces = new HashMap<>();
512512
} else {
513-
namespace = (String) namespaces.get(prefix);
513+
namespace = namespaces.get(prefix);
514514
}
515515
if (namespace == null) {
516516
final String qname = "xmlns:" + prefix;

src/main/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public String[] getPropertyNames() {
165165
if (names == null) {
166166
final DynaClass dynaClass = dynaBean.getDynaClass();
167167
final DynaProperty[] dynaProperties = dynaClass.getDynaProperties();
168-
final ArrayList properties = new ArrayList(dynaProperties.length);
168+
final ArrayList<String> properties = new ArrayList<>(dynaProperties.length);
169169
for (final DynaProperty element : dynaProperties) {
170170
final String name = element.getName();
171171
if (!CLASS.equals(name)) {

src/main/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public class JDOMAttributeIterator implements NodeIterator {
3535

3636
private NodePointer parent;
37-
private List attributes;
37+
private List<Attribute> attributes;
3838
private int position = 0;
3939

4040
/**
@@ -68,16 +68,16 @@ public JDOMAttributeIterator(final NodePointer parent, final QName name) {
6868
}
6969
final String lname = name.getName();
7070
if (!lname.equals("*")) {
71-
attributes = new ArrayList();
71+
attributes = new ArrayList<>();
7272
final Attribute attr = element.getAttribute(lname, ns);
7373
if (attr != null) {
7474
attributes.add(attr);
7575
}
7676
} else {
77-
attributes = new ArrayList();
78-
final List allAttributes = element.getAttributes();
77+
attributes = new ArrayList<>();
78+
final List<Attribute> allAttributes = element.getAttributes();
7979
for (int i = 0; i < allAttributes.size(); i++) {
80-
final Attribute attr = (Attribute) allAttributes.get(i);
80+
final Attribute attr = allAttributes.get(i);
8181
if (ns == Namespace.NO_NAMESPACE || attr.getNamespace().equals(ns)) {
8282
attributes.add(attr);
8383
}

src/main/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public int compareChildNodePointers(final NodePointer pointer1, final NodePointe
376376
return 0; // Should not happen
377377
}
378378
if (!(node instanceof Element)) {
379-
throw new IllegalStateException("JXPath internal error: " + "compareChildNodes called for " + node);
379+
throw new IllegalStateException("JXPath internal error: compareChildNodes called for " + node);
380380
}
381381
final List children = ((Element) node).getContent();
382382
final int length = children.size();
@@ -436,7 +436,7 @@ public NodePointer createChild(final JXPathContext context, final QName name, in
436436
return it.getNodePointer();
437437
}
438438
}
439-
throw new JXPathAbstractFactoryException("Factory could not create " + "a child node for path: " + asPath() + "/" + name + "[" + (index + 1) + "]");
439+
throw new JXPathAbstractFactoryException("Factory could not create a child node for path: " + asPath() + "/" + name + "[" + (index + 1) + "]");
440440
}
441441

442442
@Override

0 commit comments

Comments
 (0)