Package juuxel.ripple.util
Class Identifier
java.lang.Object
juuxel.ripple.util.Identifier
public final class Identifier
extends java.lang.Object
A namespaced identifier containing a namespace and a path.
The namespace should be a unique string such as the name of your project.
The path should be unique within the namespace. For example, the ID ripple:rename
has the namespace ripple
and the path rename
.
The string format of an identifier is namespace:path
, like with the IDs used in Minecraft.
Both components of an identifier can only contain lowercase ASCII letters (a-z
), numbers (0-9
),
underscores (_
) and periods (.
).
- Since:
- 0.2.0
-
Constructor Summary
Constructors Constructor Description Identifier(java.lang.String identifier)
Parses a string in thenamespace:path
format into an identifier.Identifier(java.lang.String namespace, java.lang.String path)
Constructs an identifier from a namespace and a path. -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getNamespace()
Gets the namespace of this ID.java.lang.String
getPath()
Gets the path of this ID.int
hashCode()
blue.endless.jankson.JsonPrimitive
toJson()
Converts this ID to a JSON primitive.java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
Identifier
public Identifier(java.lang.String namespace, java.lang.String path)Constructs an identifier from a namespace and a path.- Parameters:
namespace
- the namespacepath
- the path- Throws:
java.lang.IllegalArgumentException
- if the format is invalid
-
Identifier
public Identifier(java.lang.String identifier)Parses a string in thenamespace:path
format into an identifier.- Parameters:
identifier
- the parsed identifier string- Throws:
java.lang.IllegalArgumentException
- if the format is invalid
-
-
Method Details
-
getNamespace
public java.lang.String getNamespace()Gets the namespace of this ID.- Returns:
- the namespace
-
getPath
public java.lang.String getPath()Gets the path of this ID.- Returns:
- the path
-
toJson
public blue.endless.jankson.JsonPrimitive toJson()Converts this ID to a JSON primitive.- Returns:
- the serialised JSON form of this ID
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-