Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public int getChildCount() {
*/
public Enumeration children() {
return childBuffer != null
? new _ArrayEnumeration(childBuffer, childCount)
: Collections.enumeration(Collections.EMPTY_LIST);
? new _ArrayEnumeration<>(childBuffer, childCount)
: Collections.emptyEnumeration();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import java.util.NoSuchElementException;

/** Don't use this; used internally by FreeMarker, might change without notice. */
public class _ArrayEnumeration implements Enumeration {
public class _ArrayEnumeration<E> implements Enumeration<E> {

private final Object[] array;
private final E[] array;
private final int size;
private int nextIndex;

public _ArrayEnumeration(Object[] array, int size) {
public _ArrayEnumeration(E[] array, int size) {
this.array = array;
this.size = size;
this.nextIndex = 0;
Expand All @@ -41,7 +41,7 @@ public boolean hasMoreElements() {
}

@Override
public Object nextElement() {
public E nextElement() {
if (nextIndex >= size) {
throw new NoSuchElementException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import java.util.NoSuchElementException;

/** Don't use this; used internally by FreeMarker, might change without notice. */
public class _ArrayIterator implements Iterator {
public class _ArrayIterator<E> implements Iterator<E> {

private final Object[] array;
private final E[] array;
private int nextIndex;

public _ArrayIterator(Object[] array) {
public _ArrayIterator(E[] array) {
this.array = array;
this.nextIndex = 0;
}
Expand All @@ -39,7 +39,7 @@ public boolean hasNext() {
}

@Override
public Object next() {
public E next() {
if (nextIndex >= array.length) {
throw new NoSuchElementException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean contains(Object o) {

@Override
public Iterator<E> iterator() {
return new _ArrayIterator(array);
return new _ArrayIterator<>(array);
}

@Override
Expand Down