Skip to content

Commit cd1f5be

Browse files
committed
Add generics to _ArrayIterator and _ArrayEnumeration
1 parent 30a6e32 commit cd1f5be

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

freemarker-core/src/main/java/freemarker/core/TemplateElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public int getChildCount() {
220220
*/
221221
public Enumeration children() {
222222
return childBuffer != null
223-
? new _ArrayEnumeration(childBuffer, childCount)
224-
: Collections.enumeration(Collections.EMPTY_LIST);
223+
? new _ArrayEnumeration<>(childBuffer, childCount)
224+
: Collections.emptyEnumeration();
225225
}
226226

227227
/**

freemarker-core/src/main/java/freemarker/core/_ArrayEnumeration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
import java.util.NoSuchElementException;
2424

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

28-
private final Object[] array;
28+
private final E[] array;
2929
private final int size;
3030
private int nextIndex;
3131

32-
public _ArrayEnumeration(Object[] array, int size) {
32+
public _ArrayEnumeration(E[] array, int size) {
3333
this.array = array;
3434
this.size = size;
3535
this.nextIndex = 0;
@@ -41,7 +41,7 @@ public boolean hasMoreElements() {
4141
}
4242

4343
@Override
44-
public Object nextElement() {
44+
public E nextElement() {
4545
if (nextIndex >= size) {
4646
throw new NoSuchElementException();
4747
}

freemarker-core/src/main/java/freemarker/core/_ArrayIterator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import java.util.NoSuchElementException;
2424

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

28-
private final Object[] array;
28+
private final E[] array;
2929
private int nextIndex;
3030

31-
public _ArrayIterator(Object[] array) {
31+
public _ArrayIterator(E[] array) {
3232
this.array = array;
3333
this.nextIndex = 0;
3434
}
@@ -39,7 +39,7 @@ public boolean hasNext() {
3939
}
4040

4141
@Override
42-
public Object next() {
42+
public E next() {
4343
if (nextIndex >= array.length) {
4444
throw new NoSuchElementException();
4545
}

freemarker-core/src/main/java/freemarker/core/_SortedArraySet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public boolean contains(Object o) {
4444

4545
@Override
4646
public Iterator<E> iterator() {
47-
return new _ArrayIterator(array);
47+
return new _ArrayIterator<>(array);
4848
}
4949

5050
@Override

0 commit comments

Comments
 (0)