Class VectorUtils
- java.lang.Object
-
- org.eclipse.persistence.internal.oxm.VectorUtils
-
public class VectorUtils extends Object
This class provides "empty" and "unmodifiable" wrappers for the Vector class. The functionality is similar the Collections class and mostly copy-paste from the class. Unfortunately, the standard Collections class does not provides wrappers for the outdated Vector class.- See Also:
Collections
-
-
Field Summary
Fields Modifier and Type Field Description static Vector
EMPTY_VECTOR
The empty vector (immutable).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Vector<T>
emptyVector()
Returns an empty vector (immutable).static <T> Vector<T>
unmodifiableVector(Vector<? extends T> vector)
Returns an unmodifiable view of the specified vector.
-
-
-
Field Detail
-
EMPTY_VECTOR
public static final Vector EMPTY_VECTOR
The empty vector (immutable).- See Also:
emptyVector()
-
-
Method Detail
-
unmodifiableVector
public static <T> Vector<T> unmodifiableVector(Vector<? extends T> vector)
Returns an unmodifiable view of the specified vector. This method allows modules to provide users with "read-only" access to internal vectors. Query operations on the returned vector "read through" to the specified vector, and attempts to modify the returned vector, whether direct or via its iterator, result in anUnsupportedOperationException
.- Type Parameters:
T
- the class of the objects in the vector- Parameters:
vector
- the vector for which an unmodifiable view is to be returned.- Returns:
- an unmodifiable view of the specified vector.
-
emptyVector
public static final <T> Vector<T> emptyVector()
Returns an empty vector (immutable).This example illustrates the type-safe way to obtain an empty vector:
Vector<String> s = VectorUtils.emptyVector();
- Type Parameters:
T
- type of elements, if there were any, in the vector- Returns:
- an empty immutable vector
Implementation Note: Implementations of this method need not create a separate
Vector
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.) - See Also:
EMPTY_VECTOR
-
-