public final class IntPath extends Object implements Comparable<IntPath>, Iterable<Integer>, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
IntPath.Builder
A builder for IntPaths.
|
| Modifier and Type | Method and Description |
|---|---|
IntPath |
appending(int value)
Create a new path appending the passed value.
|
IntPath |
appending(IntPath other)
Create a new IntPath of this one concatenated with another.
|
static IntPath.Builder |
builder()
Create a builder for int paths.
|
static IntPath.Builder |
builder(int first)
Create a builder for int paths.
|
IntPath |
childPath()
Create a new path, lopping off the first element.
|
int |
compareTo(IntPath o) |
boolean |
contains(int val)
Determine if this path contains the passed value.
|
boolean |
contains(IntPath path)
Determine if this path contains the subsequence in the passed path, or is
equal to it.
|
int |
end() |
boolean |
endsWith(IntPath other)
Determine if this path ends with (or is equal to) another path.
|
boolean |
equals(Object o) |
int |
first()
Get the first path element
|
void |
forEachInt(IntConsumer c)
Iterate all elements of the path, passing them to the passed consumer.
|
void |
forEachIntReversed(IntConsumer c)
Iterate all elements of the path in reverse order, passing them to the
passed consumer.
|
int |
get(int index)
Get the path element at the specified index.
|
int |
hashCode() |
int |
indexOf(int val)
Get the first occurrence of the passed value in this path.
|
int |
indexOf(int from,
int val)
Get the first occurrence of the passed value in this path.
|
boolean |
isEmpty()
Determine if this path is empty.
|
boolean |
isNotAPath()
Determine if this path does not represent an actual path - if it has one
element or less.
|
int[] |
items()
Get the contents of this path as an int[].
|
void |
iterate(IntConsumer cons)
Deprecated.
use the better-named
forEachInt() |
Iterator<Integer> |
iterator() |
int |
last()
Get the last path element
|
int |
lastIndexOf(int val)
Get the first occurrence of the passed value in this path.
|
int |
lastIndexOf(int from,
int val)
Get the last occurrence of the passed value in this path.
|
static IntPath |
of(Collection<? extends Integer> ints) |
static IntPath |
of(int... items)
Create an IntPath from an array of ints.
|
static IntPath |
ofUnsafe(int... items)
Create an IntPath from an array of ints, using the passed array directly
rather than copying it.
|
IntPath |
parentPath()
Create a new path, lopping off the last element.
|
static IntPath |
parse(String val)
Creates an IntPath from a comma-delimited list of integers (which may
contain whitespace), such as the output of
toString(). |
IntPath |
prepending(int value)
Create a new path prepending the passed value.
|
IntPath |
reversed()
Create a new path whose elements are this one's in reverse order.
|
int |
size()
Get the number of elements in this path.
|
int |
start() |
boolean |
startsWith(IntPath other)
Determine if this path starts with (or is equal to) another path.
|
IntPath |
subPath(int start,
int end)
Get a subpath.
|
int |
sum() |
IntPath.Builder |
toBuilder()
Create a builder initialized from this path.
|
<T> ObjectPath<T> |
toObjectPath(IndexedResolvable<T> indexed)
Create an ObjectPath from this IntPath.
|
<T> ObjectPath<T> |
toObjectPath(List<T> indexed)
Create an ObjectPath from this IntPath.
|
<T extends Comparable<T>> |
toObjectPath(T... indexed)
Create an ObjectPath from this IntPath.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic static IntPath of(Collection<? extends Integer> ints)
public static IntPath parse(String val)
toString().val - A stringNumberFormatException - If the text contains non-comma,
non-whitespace, non-digit characterspublic IntPath appending(IntPath other)
other - The other pathpublic IntPath prepending(int value)
value - A valueIllegalArgumentException - if the value is negativepublic IntPath appending(int value)
value - A valueIllegalArgumentException - if the value is negativepublic void forEachInt(IntConsumer c)
c - A consumerpublic void forEachIntReversed(IntConsumer c)
c - A consumerpublic int first()
IndexOutOfBoundsException - if out of rangepublic int last()
IndexOutOfBoundsException - if out of rangepublic static IntPath of(int... items)
items - An array of intspublic static IntPath ofUnsafe(int... items)
items - An array of intspublic static IntPath.Builder builder()
public static IntPath.Builder builder(int first)
first - The first elementpublic IntPath.Builder toBuilder()
public IntPath childPath()
public IntPath parentPath()
public IntPath reversed()
public boolean startsWith(IntPath other)
other - Another pathpublic boolean endsWith(IntPath other)
other - Another pathpublic IntPath subPath(int start, int end)
start - The start index, inclusiveend - The end index, exclusiveIllegalArgumentException - if the arguments are out of range or
invalidpublic int start()
public int end()
public boolean contains(IntPath path)
path - A pathpublic int indexOf(int val)
val - An integer path elementpublic int indexOf(int from,
int val)
from - The index to start searching atval - An integer path elementpublic int lastIndexOf(int from,
int val)
from - The index to stop searching atval - An integer path elementpublic int lastIndexOf(int val)
val - An integer path elementpublic boolean contains(int val)
val - A valuepublic boolean isEmpty()
public int size()
public boolean isNotAPath()
public int get(int index)
index - The index within the pathpublic int[] items()
@Deprecated public void iterate(IntConsumer cons)
forEachInt()cons - public final int sum()
public <T> ObjectPath<T> toObjectPath(List<T> indexed)
T - The object typeindexed - A list of objects@SafeVarargs public final <T extends Comparable<T>> ObjectPath<T> toObjectPath(T... indexed)
T - The object typeindexed - An array of comparable itemspublic <T> ObjectPath<T> toObjectPath(IndexedResolvable<T> indexed)
T - The object typeindexed - An IndexedResolvable (has static methods to wrap lists,
etc.)public int compareTo(IntPath o)
compareTo in interface Comparable<IntPath>Copyright © 2010–2020 Mastfrog Technologies. All rights reserved.