Package org.spongepowered.api.resource
Interface ResourcePath
-
- All Superinterfaces:
java.lang.Comparable<ResourcePath>
public interface ResourcePath extends java.lang.Comparable<ResourcePath>
- See Also:
ResourceKey
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ResourcePath.Factory
A factory to createResourcePath
s.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
baseName()
Gets the base name of the file without any parent elements or extensions.java.lang.String
extension()
Gets the extension of the file if any.ResourceKey
key()
Gets the backingResourceKey
for this path object.java.lang.String
name()
Gets the name of the file without any parent elements.default java.lang.String
namespace()
Gets the namespace portion of this resource path.static ResourcePath
of(java.lang.String namespace, java.lang.String path)
Creates a resource path.static ResourcePath
of(ResourceKey key)
Creates a new path using the givenResourceKey
.static ResourcePath
of(org.spongepowered.plugin.PluginContainer container, java.lang.String path)
Creates a resource path from a plugin container.java.util.Optional<ResourcePath>
parent()
static ResourcePath
parse(java.lang.String value)
Parses a path from a string, generally formatted "namespace:path".default java.lang.String
path()
Gets the path portion of this resource path.ResourcePath
resolve(java.lang.String first, java.lang.String... children)
Resolves a path from the current location using the specified children.ResourcePath
resolveSibling(java.lang.String sibling, java.lang.String... children)
Resolves a sibling of this path.
-
-
-
Method Detail
-
of
static ResourcePath of(java.lang.String namespace, java.lang.String path)
Creates a resource path.- Parameters:
namespace
- The namespacepath
- The path within the supplied namespace- Returns:
- A new resource path
- See Also:
ResourceKey.of(String, String)
-
of
static ResourcePath of(org.spongepowered.plugin.PluginContainer container, java.lang.String path)
Creates a resource path from a plugin container.- Parameters:
container
- The plugin containerpath
- The path within the supplied namespace- Returns:
- A new resource path
- See Also:
ResourceKey.of(PluginContainer, String)
-
parse
static ResourcePath parse(java.lang.String value)
Parses a path from a string, generally formatted "namespace:path".If no namespace is found in
value
thenminecraft
will be the namespace.- Parameters:
value
- The value- Returns:
- A new resource path
- See Also:
ResourceKey.resolve(String)
-
of
static ResourcePath of(ResourceKey key)
Creates a new path using the givenResourceKey
.- Parameters:
key
- The key object- Returns:
- A new path
-
key
ResourceKey key()
Gets the backingResourceKey
for this path object.- Returns:
- The key object
-
namespace
default java.lang.String namespace()
Gets the namespace portion of this resource path.- Returns:
- The namespace
- See Also:
Key.namespace()
-
path
default java.lang.String path()
Gets the path portion of this resource path.- Returns:
- The path
- See Also:
Key.value()
-
parent
java.util.Optional<ResourcePath> parent()
- Returns:
- The parent path or
Optional.empty()
if there is none
-
resolve
ResourcePath resolve(java.lang.String first, java.lang.String... children)
Resolves a path from the current location using the specified children.- Parameters:
first
- The first childchildren
- The rest of the children- Returns:
- The resolvedIllegalArgumentException path
- Throws:
java.lang.IllegalArgumentException
- If the path is invalid
-
resolveSibling
ResourcePath resolveSibling(java.lang.String sibling, java.lang.String... children)
Resolves a sibling of this path.- Parameters:
sibling
- The sibling's namechildren
- The optional children of the sibling- Returns:
- The sibling resource path
- Throws:
java.lang.IllegalArgumentException
- If the path is invalid
-
name
java.lang.String name()
Gets the name of the file without any parent elements.- Returns:
- The file name
-
baseName
java.lang.String baseName()
Gets the base name of the file without any parent elements or extensions.- Returns:
- The base file name
-
extension
java.lang.String extension()
Gets the extension of the file if any. If the file has no extension, an empty string is returned.- Returns:
- The file extension
-
-