Interface NamespacedId
- All Known Implementing Classes:
ComponentId, FontId, SpriteId, ThemeId
public interface NamespacedId
An id written as
namespace:path: a ComponentId, a ThemeId, a SpriteId or a
FontId.
All four follow one grammar, which check(String, String, String) enforces and parse(String, String, BiFunction) reads. The namespace is one or
more characters with no colon, and the path one or more characters of any kind, colons included. Parsing splits
at the first colon, so an id's toString(), which is namespace:path, parses back to an equal id.
Do not implement this interface. The four records are the only kinds of id. It is not sealed because a sealed type in a jar without a module descriptor must keep its subtypes in its own package.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidChecks the parts of an id against the grammar.Returns the namespace.static <I extends NamespacedId>
IParsesnamespace:path, splitting at the first colon, and makes the id from the two parts.path()Returns the path.
-
Method Details
-
namespace
String namespace()Returns the namespace.- Returns:
- the owner, usually the id of the application or library; not empty, and without a colon
-
path
String path()Returns the path.- Returns:
- the name within the namespace; not empty, and may hold colons
-
check
Checks the parts of an id against the grammar. The records call it from their constructors.- Parameters:
kind- what is named, such as"Sprite", for the messagenamespace- the namespacepath- the path- Throws:
IllegalArgumentException- if either part is empty, or the namespace holds a colon
-
parse
Parsesnamespace:path, splitting at the first colon, and makes the id from the two parts. A missing namespace is an error, so an id never lands in another namespace by accident.- Type Parameters:
I- the kind of id- Parameters:
kind- what is named, such as"Sprite", for the messageid- the text to parsemaker- makes the id from its namespace and path, checking them- Returns:
- the id
- Throws:
IllegalArgumentException- if there is no colon, or either side of it is empty
-