Skip to content

Namespaced identifier improvements - #93

Merged
SpaceWalkerRS merged 3 commits into
gen2from
namespaced-identifier-improvements
Oct 30, 2026
Merged

SpaceWalkerRS merged 3 commits into
gen2from
namespaced-identifier-improvements

Conversation

@SpaceWalkerRS

Copy link
Copy Markdown
Member

Adds new functionality to NamespacedIdentifier and new utility methods to NamespacedIdentifiers.

NamespacedIdentifier

New methods:

  • separator(): returns the char used as the separator in the String-representation of the namespaced identifier. This separator character is also used to check equality.
  • namespaced(String): returns a copy of the namespaced identifier with the given namespace.
  • subidentifier(int) and subidentifier(int, int): similar to String's substring methods; returns a copy of the namespaced identifier where the identifier is a substring of the orignal identifier.

Examples:

NamespacedIdentifier identifier = NamespacedIdentifiers.from("example", "recipes/cookie.json");

identifier.separator(); // returns ':', String-representation: example:recipes/cookie.json
identifier = identifier.namespaced("minecraft"); // -> minecraft:recipes/cookie.json
identifier = identifier.subidentifier(8); // -> minecraft:cookie.json
identifier = identifier.subidentifier(6, 11); // -> minecraft:cookie

NamespacedIdentifiers

New methods:

  • isValid(NamespacedIdentifier): returns whether the given namespaced identifier conforms to spec (only chars a-z0-9-._/ allowed).
  • isValidNamespace(String): returns whether the given String is a valid namespace.
  • isValidIdentifier(String): returns whether the given String is a valid identifier.
  • isCharAllowed(char): returns whether the given char is allowed in the String representation of a namespaced identifier.

Other changes:

  • equals(NamespacedIdentifier, NamespacedIdentifier) now compares the separator() chars in addition to the namespace and identifier Strings.

@SpaceWalkerRS SpaceWalkerRS added the enhancement New feature or request label Oct 18, 2026
@SpaceWalkerRS
SpaceWalkerRS merged commit 6e62a1a into gen2 Oct 30, 2026
2 checks passed
@SpaceWalkerRS
SpaceWalkerRS deleted the namespaced-identifier-improvements branch October 30, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants