Revision: 440
http://xmlunit.svn.sourceforge.net/xmlunit/?rev=440&view=rev
Author: bodewig
Date: 2010-08-30 07:57:04 +0000 (Mon, 30 Aug 2010)
Log Message:
-----------
implement cast() in terms of map()
Modified Paths:
--------------
trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java
Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java
===================================================================
--- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-08-30 07:53:46 UTC (rev 439)
+++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-08-30 07:57:04 UTC (rev 440)
@@ -31,11 +31,11 @@
}
public static <E> Iterable<E> cast(final Iterable i) {
- return new Iterable<E>() {
- public Iterator<E> iterator() {
- return new CastingIterator<E>(i.iterator());
- }
- };
+ return map(i, new Mapper<Object, E>() {
+ public E map(Object o) {
+ return (E) o;
+ }
+ });
}
public static <E> Iterable<E> singleton(final E single) {
@@ -59,22 +59,6 @@
T map(F from);
}
- private static class CastingIterator<E> implements Iterator<E> {
- private final Iterator i;
- private CastingIterator(Iterator i) {
- this.i = i;
- }
- public void remove() {
- i.remove();
- }
- public E next() {
- return (E) i.next();
- }
- public boolean hasNext() {
- return i.hasNext();
- }
- }
-
private static class OnceOnlyIterator<E> implements Iterator<E> {
private final E element;
private boolean iterated = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|