Package com.storedobject.common
Class StringList
java.lang.Object
com.storedobject.common.StringList
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]Internal array to hold theStringvalues.static final StringListA constant representing an empty StringList instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAlways throwsUnsupportedOperationExceptionas StringList is immutable.booleanAlways throwsUnsupportedOperationExceptionas StringList is immutable.booleanaddAll(int index, Collection<? extends String> c) Always throwsUnsupportedOperationExceptionas StringList is immutable.booleanaddAll(Collection<? extends String> c) Always throwsUnsupportedOperationExceptionas StringList is immutable.String[]array()Get a copy of the elements as an array.voidclear()Always throwsUnsupportedOperationExceptionas StringList is immutable.concat(StringList another) Concatenate another list to this list.static StringListconcat(StringList... lists) Concatenate an array of lists.static StringListconcat(StringList first, StringList second) Concatenate 2 lists..Concatenate another list to this list.static StringListConcatenate an array of lists.concat(Collection<String> collection) Concatenate a collection to this list.booleanChecks if the list contains the specified element.booleanCheck whether this list contains the given element or not.booleanCheck whether this list contains the given element or not.booleanCheck whether this list contains the given element or not.booleanCheck whether this list contains any element that matches a given predicate or not.booleanCheck whether this list contains any element that matches a given predicate or not.booleanCheck whether this list contains any element that matches a given predicate or not.booleancontainsAll(Collection<?> c) Returns true if this list contains all of the elements of the specified collection.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.intCopy the elements of this list to a buffer.static StringListcreate(StringList... list) Create a string list by concatenating one or more lists.static StringListCreate a string list from anIterable.static StringListCreate a string list.static StringListCreate a string list from an array of strings..static StringListcreate(Collection<String> collection) Create a string list from a collection.static StringListCreate a string list from anIterator.booleanCompares this StringList with another object for equality.get(int index) Returns the element at the specified position in this list.inthashCode()Returns the hash code for this StringList.intReturns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.intIndex of an element in the list.intIndex of an element in the list.intIndex of an element in the list.intReturns the index of the first occurrence of an element in the list that satisfies the given filter.intIndex of an element in the list that matches the given predicate.intIndex of an element in the list that matches the given predicate.intIndex of an element in the list that matches the given predicate.intReturns the index of the first element that matches the given predicate starting from the specified index.intIndex of an element in the list that matches the given predicate.booleanisEmpty()Checks if the list is empty.iterator()Returns an iterator over the elements in this list in proper sequence.intReturns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.Always throwsUnsupportedOperationExceptionas StringList is immutable.listIterator(int index) Always throwsUnsupportedOperationExceptionas StringList is immutable.Create another instance by mapping the elements of this list via a converter function.minus(StringList another) Remove elements from this list that are elements of another list.remove(int index) Always throwsUnsupportedOperationExceptionas StringList is immutable.booleanAlways throwsUnsupportedOperationExceptionas StringList is immutable.Remove an element from the list.booleanremoveAll(Collection<?> c) Always throwsUnsupportedOperationExceptionas StringList is immutable.booleanretainAll(Collection<?> c) Always throwsUnsupportedOperationExceptionas StringList is immutable.Always throwsUnsupportedOperationExceptionas StringList is immutable.intsize()Returns the number of elements in this list.stream()Stream the elements.subList(int index) Get a sub-list.subList(int start, int end) Get a sub-list.Object[]toArray()Returns an array containing all of the elements in this list in proper sequence.<T> T[]toArray(T[] a) Always throwsUnsupportedOperationExceptionas StringList is immutable.toString()Concatenate the elements of this list into aStringwith the given delimiter.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, toArrayMethods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
EMPTY
A constant representing an empty StringList instance. This is backed by an immutable, empty array and can be used to avoid creating new empty StringList objects unnecessarily. This constant is primarily intended for scenarios where an empty StringList is required, improving readability and reducing memory allocations. -
array
-
-
Method Details
-
create
Create a string list.- Parameters:
list- Comma delimited list.- Returns:
- String list created.
-
create
Create a string list from a collection.- Parameters:
collection- Collection.- Returns:
- String list created.
-
create
Create a string list from anIterable.- Parameters:
list- Iterable.- Returns:
- String list created.
-
create
Create a string list from anIterator.- Parameters:
list- Iterator.- Returns:
- String list created.
-
create
Create a string list from an array of strings..- Parameters:
array- Array of strings.- Returns:
- String list created.
-
create
Create a string list by concatenating one or more lists.- Parameters:
list- Lists.- Returns:
- String list created.
-
map
Create another instance by mapping the elements of this list via a converter function.- Parameters:
converter- Converter function.- Returns:
- Converted list.
-
equals
Compares this StringList with another object for equality. Two StringLists are considered equal if they contain the same strings in the same order. -
hashCode
-
add
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
addin interfaceList<String>- Parameters:
index- Index at which the element is to be inserted.element- Element to be inserted.- Throws:
UnsupportedOperationException- always.
-
addAll
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
addAllin interfaceCollection<String>- Specified by:
addAllin interfaceList<String>- Parameters:
c- Collection containing elements to be added.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
add
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
addin interfaceCollection<String>- Specified by:
addin interfaceList<String>- Parameters:
e- Element to be added.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
isEmpty
-
contains
-
toArray
-
toArray
public <T> T[] toArray(T[] a) Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
toArrayin interfaceCollection<String>- Specified by:
toArrayin interfaceList<String>- Type Parameters:
T- Type of the array elements.- Parameters:
a- The array into which the elements of the list are to be stored.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
remove
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
removein interfaceCollection<String>- Specified by:
removein interfaceList<String>- Parameters:
o- Element to be removed.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
containsAll
Returns true if this list contains all of the elements of the specified collection.- Specified by:
containsAllin interfaceCollection<String>- Specified by:
containsAllin interfaceList<String>- Parameters:
c- Collection to be checked for containment in this list.- Returns:
- true if all elements are found, false otherwise.
-
addAll
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
addAllin interfaceList<String>- Parameters:
index- Index at which the elements are to be inserted.c- Collection containing elements to be added.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
removeAll
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
removeAllin interfaceCollection<String>- Specified by:
removeAllin interfaceList<String>- Parameters:
c- Collection containing elements to be removed.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
retainAll
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
retainAllin interfaceCollection<String>- Specified by:
retainAllin interfaceList<String>- Parameters:
c- Collection containing elements to be retained.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
clear
public void clear()Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
clearin interfaceCollection<String>- Specified by:
clearin interfaceList<String>- Throws:
UnsupportedOperationException- always.
-
set
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
setin interfaceList<String>- Parameters:
index- Index of the element to replace.element- Element to be stored at the specified position.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
remove
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
removein interfaceList<String>- Parameters:
index- Index of the element to be removed.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
indexOf
-
lastIndexOf
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.- Specified by:
lastIndexOfin interfaceList<String>- Parameters:
o- Element to search for.- Returns:
- Last index of the element or -1.
-
listIterator
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
listIteratorin interfaceList<String>- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
listIterator
Always throwsUnsupportedOperationExceptionas StringList is immutable.- Specified by:
listIteratorin interfaceList<String>- Parameters:
index- Starting index.- Returns:
- Never returns.
- Throws:
UnsupportedOperationException- always.
-
get
-
size
-
array
Get a copy of the elements as an array.- Returns:
- Array containing elements of this list.
-
indexOf
Index of an element in the list.- Parameters:
element- Element.- Returns:
- Index position or -1 if not found.
-
indexOf
Index of an element in the list.- Parameters:
element- Element.from- Start the search from this position.- Returns:
- Index position or -1 if not found.
-
indexOf
Index of an element in the list.- Parameters:
element- Element.from- Start the search from this position.to- Stop the search before this position.- Returns:
- Index position or -1 if not found.
-
indexOf
Returns the index of the first occurrence of an element in the list that satisfies the given filter.- Parameters:
filter- the predicate used to test elements in the list- Returns:
- the index of the first matching element, or -1 if no element satisfies the filter
-
indexOf
Returns the index of the first element that matches the given predicate starting from the specified index.- Parameters:
filter- the predicate used to match elementsfrom- the index to start the search from (inclusive)- Returns:
- the index of the first matching element or -1 if no match is found
-
indexOf
-
indexOf
-
indexOf
Index of an element in the list that matches the given predicate.- Parameters:
filter- Filter predicate.unique- Whether uniqueness to be checked or not.from- Start the search from this position.- Returns:
- Index position or -1 if not found.
-
indexOf
Index of an element in the list that matches the given predicate.- Parameters:
filter- Filter predicate.unique- Whether uniqueness to be checked or not.from- Start the search from this position.to- Stop the search before this position.- Returns:
- Index position or -1 if not found.
-
contains
Check whether this list contains the given element or not.- Parameters:
element- Element.- Returns:
- True/false.
-
contains
Check whether this list contains the given element or not.- Parameters:
element- Element.from- Start the search from this position.- Returns:
- True/false.
-
contains
Check whether this list contains the given element or not.- Parameters:
element- Element.from- Start the search from this position.to- Stop the search before this position.- Returns:
- True/false.
-
contains
-
contains
-
contains
-
toString
-
toString
-
stream
Stream the elements.- Specified by:
streamin interfaceCollection<String>- Returns:
- Stream.
-
iterator
-
remove
Remove an element from the list.- Parameters:
element- Element to remove.- Returns:
- Modified list.
-
minus
Remove elements from this list that are elements of another list.- Parameters:
another- Another list.- Returns:
- Modified list.
-
subList
Get a sub-list.- Parameters:
index- Index from which sublist to be started.- Returns:
- Sub-list.
-
subList
Get a sub-list. -
concat
Concatenate another list to this list.- Parameters:
another- Another list.- Returns:
- Concatenated list.
-
concat
Concatenate another list to this list.- Parameters:
another- Another list.- Returns:
- Concatenated list.
-
concat
Concatenate a collection to this list.- Parameters:
collection- Collection.- Returns:
- Concatenated list.
-
concat
Concatenate 2 lists..- Parameters:
first- First list (could be null).second- Second list (could be null).- Returns:
- Concatenated list.
-
concat
Concatenate an array of lists.- Parameters:
lists- Array of lists.- Returns:
- Concatenated list.
-
concat
Concatenate an array of lists.- Parameters:
lists- Array of lists.- Returns:
- Concatenated list.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
buffer- Buffer to copy to- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
startingIndex- Starting index of the list from where copy beginsbuffer- Buffer to copy to- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
startingIndex- Starting index of the list from where copy beginscount- Number of elements to copybuffer- Buffer to copy to- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
buffer- Buffer to copy tostartingBufferIndex- Starting index of the buffer from where copy begins- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
buffer- Buffer to copy tostartingBufferIndex- Starting index of the buffer from where copy beginscount- Number of elements to copy- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer. Same ascopyTo(int, int, String[], int).- Parameters:
startingIndex- Starting index of the list from where copy beginsbuffer- Buffer to copy tostartingBufferIndex- Starting index of the buffer from where copy beginscount- Number of elements to copy- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-
copyTo
Copy the elements of this list to a buffer.- Parameters:
startingIndex- Starting index of the list from where copy beginscount- Number of elements to copybuffer- Buffer to copy tostartingBufferIndex- Starting index of the buffer from where copy begins- Returns:
- Number of elements copied. Zero will be returned if
bufferisnull.
-