-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
b49
-
generic
-
generic
When the Collections Framework was generified, the three "empty collection" constants (Collections.emptySet, emptyList and emptyMap) were supplemented with parameterized methods to provide typesafe empty collections. Due to an oversight, the new methods (Collections.emptySet(), emptyList() and emptyMap()) lack documentation.
The following documentation should suffice:
/**
* Returns the empty set (immutable). This set is serializable.
* Unlike the like-named field, this method is parameterized.
*
* <p>This example illustrates the type-safe way to obtain an empty set:
* <pre>
* Set<String> s = Collections.emptySet();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>Set</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <T> Set<T> emptySet()
/**
* Returns the empty list (immutable). This list is serializable.
*
* <p>This example illustrates the type-safe way to obtain an empty list:
* <pre>
* List<String> s = Collections.emptyList();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>List</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <T> List<T> emptyList()
/**
* Returns the empty map (immutable). This map is serializable.
*
* <p>This example illustrates the type-safe way to obtain an empty set:
* <pre>
* Map<String, Date> s = Collections.emptyMap();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>Map</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <K,V> Map<K,V> emptyMap()
The following documentation should suffice:
/**
* Returns the empty set (immutable). This set is serializable.
* Unlike the like-named field, this method is parameterized.
*
* <p>This example illustrates the type-safe way to obtain an empty set:
* <pre>
* Set<String> s = Collections.emptySet();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>Set</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <T> Set<T> emptySet()
/**
* Returns the empty list (immutable). This list is serializable.
*
* <p>This example illustrates the type-safe way to obtain an empty list:
* <pre>
* List<String> s = Collections.emptyList();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>List</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <T> List<T> emptyList()
/**
* Returns the empty map (immutable). This map is serializable.
*
* <p>This example illustrates the type-safe way to obtain an empty set:
* <pre>
* Map<String, Date> s = Collections.emptyMap();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>Map</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @since 1.5
*/
public static final <K,V> Map<K,V> emptyMap()