public class HDPath extends java.util.AbstractList<ChildNumber>
HDPath
can be used to represent a full path or a relative path.
The hasPrivateKey
boolean
is used for rendering to String
but (at present) not much else. It defaults to false
which is the preferred setting for a relative path.
HDPath
is immutable and uses the Collections.UnmodifiableList
type internally.
It implements java.util.List<ChildNumber>
to ease migration
from the previous Guava ImmutableList<ChildNumber>
. It should be a minor breaking change
to replace ImmutableList<ChildNumber>
with List<ChildNumber>
where necessary in your code. Although
it is recommended to use the HDPath
type for clarity and for access to HDPath
-specific functionality.
Take note of the overloaded factory methods M()
and m()
. These can be used to very
concisely create HDPath objects (especially when statically imported.)
Modifier and Type | Field and Description |
---|---|
protected boolean |
hasPrivateKey |
protected java.util.List<ChildNumber> |
unmodifiableList |
Constructor and Description |
---|
HDPath(boolean hasPrivateKey,
java.util.List<ChildNumber> list)
Constructs a path for a public or private key.
|
HDPath(java.util.List<ChildNumber> list)
Constructs a path for a public key.
|
Modifier and Type | Method and Description |
---|---|
HDPath |
extend(ChildNumber child1,
ChildNumber... children)
Extend the path by appending additional ChildNumber objects.
|
HDPath |
extend(HDPath path2)
Extend the path by appending a relative path.
|
HDPath |
extend(java.util.List<ChildNumber> path2)
Extend the path by appending a relative path.
|
ChildNumber |
get(int index) |
boolean |
hasPrivateKey()
Is this a path to a private key?
|
static HDPath |
m()
Returns an empty path for a private key.
|
static HDPath |
M()
Returns an empty path for a public key.
|
static HDPath |
m(ChildNumber... children)
Returns a path for a private key.
|
static HDPath |
M(ChildNumber... children)
Returns a path for a public key.
|
static HDPath |
m(ChildNumber childNumber)
Returns a path for a private key.
|
static HDPath |
M(ChildNumber childNumber)
Returns a path for a public key.
|
static HDPath |
m(java.util.List<ChildNumber> list)
Returns a path for a private key.
|
static HDPath |
M(java.util.List<ChildNumber> list)
Returns a path for a public key.
|
static HDPath |
parsePath(java.lang.String path)
Create an HDPath from a path string.
|
int |
size() |
java.lang.String |
toString() |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected final boolean hasPrivateKey
protected final java.util.List<ChildNumber> unmodifiableList
public HDPath(boolean hasPrivateKey, java.util.List<ChildNumber> list)
hasPrivateKey
- Whether it is a path to a private key or notlist
- List of children in the pathpublic HDPath(java.util.List<ChildNumber> list)
list
- List of children in the pathpublic static HDPath M(java.util.List<ChildNumber> list)
list
- List of children in the pathpublic static HDPath M()
public static HDPath M(ChildNumber childNumber)
childNumber
- Single child in pathpublic static HDPath M(ChildNumber... children)
children
- Children in the pathpublic static HDPath m(java.util.List<ChildNumber> list)
list
- List of children in the pathpublic static HDPath m()
public static HDPath m(ChildNumber childNumber)
childNumber
- Single child in pathpublic static HDPath m(ChildNumber... children)
children
- Children in the pathpublic static HDPath parsePath(@Nonnull java.lang.String path)
public boolean hasPrivateKey()
public HDPath extend(ChildNumber child1, ChildNumber... children)
child1
- the first child to appendchildren
- zero or more additional children to appendpublic HDPath extend(HDPath path2)
path2
- the relative path to appendpublic HDPath extend(java.util.List<ChildNumber> path2)
path2
- the relative path to appendpublic ChildNumber get(int index)
get
in interface java.util.List<ChildNumber>
get
in class java.util.AbstractList<ChildNumber>
public int size()
size
in interface java.util.Collection<ChildNumber>
size
in interface java.util.List<ChildNumber>
size
in class java.util.AbstractCollection<ChildNumber>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<ChildNumber>