Class Lists
- java.lang.Object
-
- io.microsphere.collection.Lists
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> java.util.List<E>
ofList()
Returns an empty unmodifiable list.static <E> java.util.List<E>
ofList(E e1)
Returns an unmodifiable list containing one element.static <E> java.util.List<E>
ofList(E... elements)
Returns an unmodifiable list containing the specified elements.static <E> java.util.List<E>
ofList(E e1, E e2)
Returns an unmodifiable list containing two elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3)
Returns an unmodifiable list containing three elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3, E e4)
Returns an unmodifiable list containing four elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3, E e4, E e5)
Returns an unmodifiable list containing five elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
Returns an unmodifiable list containing seven elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
Returns an unmodifiable list containing eight elements.static <E> java.util.List<E>
ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
Returns an unmodifiable list containing nine elements.
-
-
-
Method Detail
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList()
Returns an empty unmodifiable list.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> emptyList = Lists.ofList();
- Type Parameters:
E
- the element type of the list- Returns:
- an empty unmodifiable list
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1)
Returns an unmodifiable list containing one element.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> singleElementList = Lists.ofList("Hello");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the single element- Returns:
- a
List
containing the specified element - Throws:
java.lang.NullPointerException
- if the element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2)
Returns an unmodifiable list containing two elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> twoElementList = Lists.ofList("Hello", "World");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3)
Returns an unmodifiable list containing three elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> threeElementList = Lists.ofList("Hello", "World", "Java");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3, E e4)
Returns an unmodifiable list containing four elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> fourElementList = Lists.ofList("Hello", "World", "Java", "Lists");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3, E e4, E e5)
Returns an unmodifiable list containing five elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> fiveElementList = Lists.ofList("Hello", "World", "Java", "Lists", "Example");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
Returns an unmodifiable list containing seven elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> sevenElementList = Lists.ofList("Hello", "World", "Java", "Lists", "Example", "Seven", "Elements");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth elemente6
- the sixth elemente7
- the seventh element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
Returns an unmodifiable list containing eight elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> eightElementList = Lists.ofList("Hello", "World", "Java", "Lists", "Example", "Eight", "Elements", "Demo");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth elemente6
- the sixth elemente7
- the seventh elemente8
- the eighth element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
Returns an unmodifiable list containing nine elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> nineElementList = Lists.ofList("Hello", "World", "Java", "Lists", "Example", "Nine", "Elements", "Demo", "Test");
- Type Parameters:
E
- theList
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth elemente6
- the sixth elemente7
- the seventh elemente8
- the eighth elemente9
- the ninth element- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if an element isnull
-
ofList
@Nonnull @Immutable public static <E> java.util.List<E> ofList(E... elements)
Returns an unmodifiable list containing the specified elements.The returned list is serializable and implements the
RandomAccess
interface if the implementation class allows.Example Usage
List<String> emptyList = Lists.ofList(); // returns an empty list List<String> singleElementList = Lists.ofList("Hello"); // returns a list with one element List<String> multiElementList = Lists.ofList("Hello", "World", "Java"); // returns a list with multiple elements
- Type Parameters:
E
- theList
's element type- Parameters:
elements
- the elements to be included in the list- Returns:
- a
List
containing the specified elements - Throws:
java.lang.NullPointerException
- if any element isnull
-
-