Author: hlship
Date: Sun Jan 7 14:45:34 2007
New Revision: 493870
URL: http://svn.apache.org/viewvc?view=rev&rev=493870
Log:
Tweak the generics to a) make the very stupid Sun JDK happy and b) support
creating collections from compatible subclasses or implementations.
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java?view=diff&rev=493870&r1=493869&r2=493870
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
Sun Jan 7 14:45:34 2007
@@ -61,14 +61,15 @@
}
/** Contructs a new [EMAIL PROTECTED] HashSet} and initializes it using
the provided collection. */
- public static <T> Set<T> newSet(Collection<? extends T> values)
+ public static <T, V extends T> Set<T> newSet(Collection<V> values)
{
return new HashSet<T>(values);
}
- public static <T> Set<T> newSet(T... values)
+ public static <T, V extends T> Set<T> newSet(V... values)
{
- return newSet(Arrays.asList(values));
+ // Was a call to newSet(), but Sun JDK can't handle that. Fucking
generics.
+ return new HashSet<T>(Arrays.asList(values));
}
/**
@@ -93,9 +94,13 @@
return new ArrayList<T>();
}
- public static <T> List<T> newList(T... elements)
+ /**
+ * Creates a new, fully modifiable list from an initial set of elements.
+ */
+ public static <T, V extends T> List<T> newList(V... elements)
{
- return newList(Arrays.asList(elements));
+ // Was call to newList(), but Sun JDK can't handle that.
+ return new ArrayList<T>(Arrays.asList(elements));
}
/** Useful for queues. */
@@ -105,7 +110,7 @@
}
/** Constructs and returns a new [EMAIL PROTECTED] ArrayList} as a copy of
the provided collection. */
- public static <T> List<T> newList(Collection<? extends T> list)
+ public static <T, V extends T> List<T> newList(Collection<V> list)
{
return new ArrayList<T>(list);
}