Package revxrsal.commands.core
Class CommandPath
java.lang.Object
revxrsal.commands.core.CommandPath
- All Implemented Interfaces:
Comparable<CommandPath>
,Iterable<String>
- Direct Known Subclasses:
MutableCommandPath
Represents the full, qualified, case-insensitive path of a command.
This class is immutable, hence is thread-safe, and is intended to be used as a key for maps that use hashing.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final LinkedList<String>
Represents the actual path of this command -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(@NotNull CommandPath o) boolean
@NotNull String
get
(int index) Returns the string element at the given index.static @NotNull CommandPath
Returns the correspondingCommandPath
to the given pathstatic @NotNull CommandPath
get
(@NotNull Collection<String> path) Returns the correspondingCommandPath
to the given path@Nullable CommandPath
Returns the full path of the category of this command.@NotNull String
getFirst()
Returns the first element of this command path@NotNull String
getLast()
Returns the last element in this command path@NotNull String
getName()
Returns the name (tail) of this command path.@NotNull String
Returns the root parent of this command path.@NotNull LinkedList<String>
Returns the subcommand path of this command path.int
hashCode()
boolean
isChildOf
(CommandPath other) Tests whether is this path a child of the specified path or notboolean
Returns whether is this command path mutable or not.boolean
isParentOf
(CommandPath other) Tests whether is this path a parent of the specified path or notboolean
isRoot()
Returns whether this path represents a root command path or notiterator()
int
size()
Returns the size of this command path@NotNull LinkedList<String>
toList()
Returns a clone linked list of this path.Returns a mutable copy of this command path.@NotNull String
Converts this path to a string, where all elements in the path are joined by a space.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
path
Represents the actual path of this command
-
-
Method Details
-
get
Returns the correspondingCommandPath
to the given path- Parameters:
path
- Path to wrap- Returns:
- The command path
-
get
Returns the correspondingCommandPath
to the given path- Parameters:
path
- Path to wrap- Returns:
- The command path
-
toRealString
Converts this path to a string, where all elements in the path are joined by a space.- Returns:
- The real path
-
toList
Returns a clone linked list of this path.- Returns:
- A linked list of this path
-
getParent
Returns the root parent of this command path. This is equivilent to callinggetFirst()
.- Returns:
- The parent
-
getName
Returns the name (tail) of this command path. This is equivilent to callinggetLast()
.- Returns:
- The name
-
getFirst
Returns the first element of this command path- Returns:
- The first element
-
getLast
Returns the last element in this command path- Returns:
- The last element
-
get
Returns the string element at the given index.- Parameters:
index
- Index to fetch at- Returns:
- The string at the given index
- Throws:
IndexOutOfBoundsException
- -
-
size
public int size()Returns the size of this command path- Returns:
- The path size
-
isRoot
public boolean isRoot()Returns whether this path represents a root command path or not- Returns:
- If this path represents a root path
-
getCategoryPath
Returns the full path of the category of this command. This will return null if this path represents a root command.- Returns:
- The command category path
-
getSubcommandPath
Returns the subcommand path of this command path. This will simply drop the command's parent name.- Returns:
- The subcommand path.
-
toMutablePath
Returns a mutable copy of this command path.- Returns:
- The mutable copy.
-
isMutable
public boolean isMutable()Returns whether is this command path mutable or not.This should only return true in cases of
MutableCommandPath
.- Returns:
- Whether is the path mutable or not.
-
isChildOf
Tests whether is this path a child of the specified path or not- Parameters:
other
- Path to test against- Returns:
- True if this is a child of it, false if otherwise.
-
isParentOf
Tests whether is this path a parent of the specified path or not- Parameters:
other
- Path to test against- Returns:
- True if this is a child of it, false if otherwise.
-
equals
-
hashCode
public int hashCode() -
toString
-
iterator
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CommandPath>
-