Package se.curity.identityserver.sdk
Class NonEmptyList<T>
Object
se.curity.identityserver.sdk.NonEmptyList<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>
A Immutable List which is guaranteed to contain at least one element.
-
Method Summary
Modifier and TypeMethodDescriptionvoidOperation not supported.booleanOperation not supported.booleanaddAll(int index, @Nonnull Collection<? extends T> c) Operation not supported.booleanaddAll(@Nonnull Collection<? extends T> c) Operation not supported.voidclear()Operation not supported.booleanbooleancontainsAll(@Nonnull Collection<?> c) booleanvoidget(int index) getFirst()getLast()getTail()inthashCode()intbooleanisEmpty()iterator()intlistIterator(int index) static <E> NonEmptyList<E>of(E item) Create a non-empty List containing a single item.static <E> NonEmptyList<E>of(E[] items) Create a non-empty List from the provided list.static <E> NonEmptyList<E>Create a non-empty List from the provided Iterable.remove(int index) Operation not supported.booleanOperation not supported.booleanremoveAll(@Nonnull Collection<?> c) Operation not supported.booleanOperation not supported.voidreplaceAll(UnaryOperator<T> operator) Operation not supported.booleanretainAll(@Nonnull Collection<?> c) Operation not supported.Operation not supported.intsize()voidsort(Comparator<? super T> c) Operation not supported.stream()subList(int fromIndex, int toIndex) toArray()<T1> @Nonnull T1[]toString()Create a newNonEmptyListcontaining all items of this list plus the given item.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
toArray
-
Method Details
-
getFirst
- Returns:
- the first element of the list. Because this list is non-empty, this method never throws an Exception.
-
getLast
- Returns:
- the last element of the list. Because this list is non-empty, this method never throws an Exception.
-
getTail
- Returns:
- the tail of this list, ie. all elements except the first one.
This is very useful for cases when the list must be broken up into its head + tail elements
(
[head | [tail]]).
-
getAllExceptLast
- Returns:
- all the elements of this List, except for the last one.
This is very useful for cases when the list must be broken up into its initial part + the last element.
(
[[initial] | last]).
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
-
add
Operation not supported. This is a Immutable List.- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Parameters:
t- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
remove
Operation not supported. This is a Immutable List.- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceList<T>- Parameters:
o- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
addAll
Operation not supported. This is a Immutable List.- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceList<T>- Parameters:
c- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
addAll
Operation not supported. This is a Immutable List.- Specified by:
addAllin interfaceList<T>- Parameters:
index- not usedc- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
removeAll
Operation not supported. This is a Immutable List.- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceList<T>- Parameters:
c- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
retainAll
Operation not supported. This is a Immutable List.- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceList<T>- Parameters:
c- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
replaceAll
Operation not supported. This is a Immutable List.- Specified by:
replaceAllin interfaceList<T>- Parameters:
operator- not used- Throws:
UnsupportedOperationException- if called
-
sort
Operation not supported. This is a Immutable List.- Specified by:
sortin interfaceList<T>- Parameters:
c- not used- Throws:
UnsupportedOperationException- if called
-
clear
public void clear()Operation not supported. This is a Immutable List.- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- Throws:
UnsupportedOperationException- if called
-
equals
-
hashCode
public int hashCode() -
get
-
set
Operation not supported. This is a Immutable List.- Specified by:
setin interfaceList<T>- Parameters:
index- not usedelement- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
add
Operation not supported. This is a Immutable List.- Specified by:
addin interfaceList<T>- Parameters:
index- not usedelement- not used- Throws:
UnsupportedOperationException- if called
-
remove
Operation not supported. This is a Immutable List.- Specified by:
removein interfaceList<T>- Parameters:
index- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
subList
-
spliterator
- Specified by:
spliteratorin interfaceCollection<T>- Specified by:
spliteratorin interfaceIterable<T>- Specified by:
spliteratorin interfaceList<T>
-
removeIf
Operation not supported. This is a Immutable List.- Specified by:
removeIfin interfaceCollection<T>- Parameters:
filter- not used- Returns:
- nothing
- Throws:
UnsupportedOperationException- if called
-
stream
- Specified by:
streamin interfaceCollection<T>
-
parallelStream
- Specified by:
parallelStreamin interfaceCollection<T>
-
forEach
-
of
Create a non-empty List from the provided Iterable.- Type Parameters:
E- type of elements- Parameters:
iterable- containing at least one element.- Returns:
- a non-empty List
- Throws:
IllegalArgumentException- if the list is empty
-
of
Create a non-empty List from the provided list.- Type Parameters:
E- type of elements- Parameters:
items- containing at least one element.- Returns:
- a non-empty List
- Throws:
IllegalArgumentException- if the array is empty
-
of
Create a non-empty List containing a single item.- Type Parameters:
E- type of element- Parameters:
item- single item of the List.- Returns:
- a non-empty List
-
with
Create a newNonEmptyListcontaining all items of this list plus the given item.- Parameters:
item- to append to the list- Returns:
- the result of appending the given item to a copy of this List.
- Since:
- 2.1
-
toString
-