Package dev.siroshun.configapi.core.node
Interface ListNode
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new object to thisListNode.voidvoidaddAll(@NotNull Collection<?> collection) Adds new objects in the givenCollectionto thisListNode.@NotNull ListNodeaddList()@NotNull ListNodeaddList(int initialCapacity) @NotNull MapNodeaddMap()<T> @NotNull @Unmodifiable List<T>@NotNull @UnmodifiableView ListNodeasView()Gets a view of thisListNode.voidclear()Clears thisListNode.booleanChecks if the specified object is contained in thisListNode.@NotNull ListNodecopy()Copies thisListNode.static @NotNull ListNodecreate()Creates a newListNode.static @NotNull ListNodecreate(int initialCapacity) Creates a newListNode.static @NotNull ListNodecreate(@NotNull Collection<?> collection) Creates a newListNodewith values in the givenCollection.static @NotNull @Unmodifiable ListNodeempty()Gets aListNodethat is always empty.@NotNull Node<?>get(int index) Gets the element at the specified position in thisListNode.booleanisEmpty()Checks if thisListNodehas no element.@NotNull Node<?>remove(int index) Removes the element at the specified position in thisListNode.booleanRemoves an object from thisListNode.booleanRemoves the elements from thisListNodethat satisfy the given predicate.voidreplaceAll(@NotNull UnaryOperator<Node<?>> operator) Replaces each element in thisListNodeusing the givenUnaryOperator.@NotNull Node<?>Sets the new element at the specified position in thisListNode.intsize()Returns the number of elements in thisListNode.voidsort(@NotNull Comparator<? super Node<?>> comparator) Sorts thisListNodeusing the givenComparator.stream()Creates aStreamfrom an internal list.value()Methods inherited from interface dev.siroshun.configapi.core.node.CommentableNode
getComment, getCommentOrNull, hasComment, setCommentMethods inherited from interface dev.siroshun.configapi.core.node.Node
accept, asOptional, hasValue
-
Field Details
-
IMPLEMENTATION_CLASS
An implementationClassof this interface.
-
-
Method Details
-
create
Creates a newListNode.- Returns:
- a new
ListNode
-
create
Creates a newListNode.- Parameters:
initialCapacity- the initial capacity of the list- Returns:
- a new
ListNode
-
create
Creates a newListNodewith values in the givenCollection.- Parameters:
collection- aCollectionto add elements to the newListNode- Returns:
- a new
ListNodewith values in the givenCollection
-
empty
Gets aListNodethat is always empty.The returning
ListNodecannot be modified using methods likeadd(Object).- Returns:
- a
ListNodethat is always empty
-
value
-
asList
@NotNull <T> @NotNull @Unmodifiable List<T> asList(@NotNull @NotNull Class<? extends T> elementClass) Gets aListcontaining elements of the specifiedClass.The returning
Listis immutable.The list only contain elements such that
Class.isInstance(java.lang.Object)returnstrue. Other elements are ignored. -
stream
Creates aStreamfrom an internal list.- Returns:
- a
Streamfrom an internal list
-
add
Adds a new object to thisListNode.- Parameters:
value- a new object
-
addAll
Adds new objects in the givenCollectionto thisListNode.- Parameters:
collection- aCollectionthat includes new objects to add
-
addAll
- Parameters:
listNode- aListNodethat includes new nodes to add
-
addList
- Returns:
- a created
ListNode
-
addList
- Parameters:
initialCapacity- the initial capacity of the list- Returns:
- a created
ListNode
-
addMap
- Returns:
- a created
MapNode
-
clear
void clear()Clears thisListNode. -
contains
Checks if the specified object is contained in thisListNode.- Parameters:
object- the object to check- Returns:
trueif the specified object is contained in thisListNode, otherwisefalse
-
get
Gets the element at the specified position in thisListNode.- Parameters:
index- the index of the element to return- Returns:
- the element at the specified position
- Throws:
IndexOutOfBoundsException- if the index is out of range
-
isEmpty
boolean isEmpty()Checks if thisListNodehas no element.- Returns:
trueif thisListNodehas no element, otherwisefalse
-
remove
Removes the element at the specified position in thisListNode.- Parameters:
index- the index of the element to remove- Returns:
- the removed
Node - Throws:
IndexOutOfBoundsException- if the index is out of range
-
remove
Removes an object from thisListNode.- Parameters:
value- an object to remove from thisListNode- Returns:
trueif the specified object is removed, otherwisefalse
-
removeIf
Removes the elements from thisListNodethat satisfy the given predicate.- Parameters:
predicate- a predicate which returnstruefor elements to be removed- Returns:
trueif thisListNodeis changed, otherwisefalse
-
replaceAll
Replaces each element in thisListNodeusing the givenUnaryOperator.- Parameters:
operator- aUnaryOperatorthat replaces the elements
-
set
Sets the new element at the specified position in thisListNode.- Parameters:
index- the index of the element to setobject- the object to set- Returns:
- the removed
Node - Throws:
IndexOutOfBoundsException- if the index is out of range
-
size
int size()Returns the number of elements in thisListNode.- Returns:
- the number of elements in this
ListNode
-
sort
Sorts thisListNodeusing the givenComparator.- Parameters:
comparator- theComparatorto use for sorting thisListNode
-
copy
Copies thisListNode.The elements in this
ListNodewill also be copied usingNode.fromObject(Object).- Returns:
- a copied
ListNode
-
asView
Gets a view of thisListNode.The returning
ListNodecannot be modified, but thisListNodecan still be modified, so the elements may be changed by other codes using this instance.- Returns:
- a view of this
ListNode
-