Package com.landawn.abacus.util
Class ImmutableList<E>
java.lang.Object
java.util.AbstractCollection<E>
com.landawn.abacus.util.ImmutableCollection<E>
com.landawn.abacus.util.ImmutableList<E>
- Type Parameters:
E
-
- All Implemented Interfaces:
Immutable
,Iterable<E>
,Collection<E>
,List<E>
,SequencedCollection<E>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.boolean
addAll
(int index, Collection<? extends E> newElements) Deprecated.throwsUnsupportedOperationException
static <E> ImmutableList.Builder
<E> builder()
static <E> ImmutableList.Builder
<E> static <E> ImmutableList
<E> copyOf
(Collection<? extends E> c) Returns an ImmutableList containing the elements of the provided collection.static <E> ImmutableList
<E> empty()
Returns an empty ImmutableList.get
(int index) int
static <E> ImmutableList
<E> just
(E e) Returns an ImmutableList containing just the provided element.int
lastIndexOf
(Object valueToFind) Last index of.listIterator
(int index) static <E> ImmutableList
<E> of
(E e1) Returns an ImmutableList containing just the provided element.static <E> ImmutableList
<E> of
(E... a) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5, E e6) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5, E e6, E e7) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) Returns an ImmutableList containing the provided elements.static <E> ImmutableList
<E> of
(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) Returns an ImmutableList containing the provided elements.remove
(int index) Deprecated.throwsUnsupportedOperationException
void
replaceAll
(UnaryOperator<E> operator) Deprecated.throwsUnsupportedOperationException
Deprecated.throwsUnsupportedOperationException
void
sort
(Comparator<? super E> c) Deprecated.throwsUnsupportedOperationException
subList
(int fromIndex, int toIndex) static <E> ImmutableCollection
<E> wrap
(Collection<? extends E> c) Deprecated.throwsUnsupportedOperationException
static <E> ImmutableList
<E> Wraps the provided list into an ImmutableList.Methods inherited from class com.landawn.abacus.util.ImmutableCollection
add, addAll, clear, contains, equals, hashCode, iterator, remove, removeAll, removeIf, retainAll, size, toArray, toArray, toString
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
empty
Returns an empty ImmutableList.- Type Parameters:
E
- the type of elements in this list- Returns:
- an empty ImmutableList
-
just
Returns an ImmutableList containing just the provided element.- Type Parameters:
E
- the type of the element- Parameters:
e
- the element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided element
-
of
Returns an ImmutableList containing just the provided element.- Type Parameters:
E
- the type of the element- Parameters:
e1
- the element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided element
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableListe6
- the sixth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableListe6
- the sixth element to be included in the ImmutableListe7
- the seventh element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableListe6
- the sixth element to be included in the ImmutableListe7
- the seventh element to be included in the ImmutableListe8
- the eighth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableListe6
- the sixth element to be included in the ImmutableListe7
- the seventh element to be included in the ImmutableListe8
- the eighth element to be included in the ImmutableListe9
- the ninth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements.- Type Parameters:
E
- the type of the elements- Parameters:
e1
- the first element to be included in the ImmutableListe2
- the second element to be included in the ImmutableListe3
- the third element to be included in the ImmutableListe4
- the fourth element to be included in the ImmutableListe5
- the fifth element to be included in the ImmutableListe6
- the sixth element to be included in the ImmutableListe7
- the seventh element to be included in the ImmutableListe8
- the eighth element to be included in the ImmutableListe9
- the ninth element to be included in the ImmutableListe10
- the tenth element to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
-
of
Returns an ImmutableList containing the provided elements. And it's not backed by the specified array. If the specified array isnull
or empty, an emptyImmutableList
is returned.- Type Parameters:
E
- the type of the elements- Parameters:
a
- the elements to be included in the ImmutableList- Returns:
- an ImmutableList containing the provided elements
- See Also:
-
copyOf
Returns an ImmutableList containing the elements of the provided collection. If the provided collection is already an instance of ImmutableList, it is directly returned. If the provided collection isnull
or empty, an empty ImmutableList is returned. Otherwise, a new ImmutableList is created with the elements of the provided collection.- Type Parameters:
E
- the type of elements in the collection- Parameters:
c
- the collection whose elements are to be placed into this list- Returns:
- an ImmutableList containing the elements of the specified collection
-
wrap
Wraps the provided list into an ImmutableList. Changes to the specified List will be reflected in the ImmutableList. If the provided list is already an instance of ImmutableList, it is directly returned. If the list isnull
, an empty ImmutableList is returned. Otherwise, returned a new ImmutableList backed by the provided list.- Type Parameters:
E
- the type of elements in the list- Parameters:
list
- the list to be wrapped into an ImmutableList- Returns:
- an ImmutableList backed by the provided list
-
wrap
@Deprecated public static <E> ImmutableCollection<E> wrap(Collection<? extends E> c) throws UnsupportedOperationException Deprecated.throwsUnsupportedOperationException
This method is deprecated and will throw an UnsupportedOperationException if used.- Type Parameters:
E
-- Parameters:
c
-- Returns:
- Throws:
UnsupportedOperationException
-
get
-
indexOf
-
lastIndexOf
Last index of.- Specified by:
lastIndexOf
in interfaceList<E>
- Parameters:
valueToFind
-- Returns:
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Parameters:
index
-- Returns:
-
subList
-
addAll
@Deprecated public boolean addAll(int index, Collection<? extends E> newElements) throws UnsupportedOperationException Deprecated.throwsUnsupportedOperationException
Adds the all.- Specified by:
addAll
in interfaceList<E>
- Parameters:
index
-newElements
-- Returns:
- Throws:
UnsupportedOperationException
-
set
Deprecated.throwsUnsupportedOperationException
- Specified by:
set
in interfaceList<E>
- Parameters:
index
-element
-- Returns:
- Throws:
UnsupportedOperationException
-
add
Deprecated.throwsUnsupportedOperationException
- Specified by:
add
in interfaceList<E>
- Parameters:
index
-element
-- Throws:
UnsupportedOperationException
-
remove
Deprecated.throwsUnsupportedOperationException
- Specified by:
remove
in interfaceList<E>
- Parameters:
index
-- Returns:
- Throws:
UnsupportedOperationException
-
replaceAll
Deprecated.throwsUnsupportedOperationException
- Specified by:
replaceAll
in interfaceList<E>
- Parameters:
operator
-- Throws:
UnsupportedOperationException
-
sort
Deprecated.throwsUnsupportedOperationException
- Specified by:
sort
in interfaceList<E>
- Parameters:
c
-- Throws:
UnsupportedOperationException
-
builder
- Type Parameters:
E
-- Returns:
-
builder
- Type Parameters:
E
-- Parameters:
holder
-- Returns:
-
UnsupportedOperationException