Skip to content

Commit 0696d1c

Browse files
committed
add javadoc to NamespacedIdentifier
1 parent 6bebdc9 commit 0696d1c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

libraries/core/src/main/java/net/ornithemc/osl/core/api/util/NamespacedIdentifier.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,45 @@
22

33
import java.util.Objects;
44

5+
/**
6+
* Namespaced identifiers are two-part strings that uniquely point to content in Minecraft.
7+
* The two parts are the namespace and the identifier. They can be combined into a single
8+
* string representation as namespace:identifier (the namespace, followed by the identifier,
9+
* separated by a colon).
10+
* <p>
11+
* A namespace is a domain for content. It is used not to point to specific content, but to
12+
* differentiate between different content sources or publishers. The use of namespaces can
13+
* prevent conflicts between mods, resource packs, or data packs, in cases where the same
14+
* identifier is used.
15+
* <p>
16+
* The identifier is a unique name for content within a namespace. It should be descriptive
17+
* to avoid naming conflicts with other content. The preferred format is snake_case.
18+
* <p>
19+
* Namespaces may only contain alphanumeric characters [a-zA-Z0-9] and special characters
20+
* [-._]. Identifiers may also contain the special character [/].
21+
* <p>
22+
* This class is essentially equivalent to Vanilla's {@code Identifier}. It was added for a
23+
* few reasons. For one, Vanilla's {@code Identifier} was only added in 13w21a, and then was
24+
* client-only until 14w27b. Implementation details of this class also changed a few times,
25+
* and only since 17w43a were {@code Identifiers} validated in any way.
26+
* <br> This class is available for all Minecraft versions, without any version-specific
27+
* implementation details.
28+
*/
529
public final class NamespacedIdentifier {
630

31+
/**
32+
* The separator between the namespace and identifier in the {@code String}
33+
* representation of a {@code NamespacedIdentifier}.
34+
*/
735
public static final char SEPARATOR = ':';
836

37+
/**
38+
* The namespace of this {@code NamespacedIdentifier}.
39+
*/
940
private final String namespace;
41+
/**
42+
* The identifier of this {@code NamespacedIdentifier}.
43+
*/
1044
private final String identifier;
1145

1246
NamespacedIdentifier(String namespace, String identifier) {
@@ -36,10 +70,16 @@ public String toString() {
3670
return namespace + SEPARATOR + identifier;
3771
}
3872

73+
/**
74+
* @return the namespace of this {@code NamespacedIdentifier}.
75+
*/
3976
public String getNamespace() {
4077
return namespace;
4178
}
4279

80+
/**
81+
* @return the identifier of this {@code NamespacedIdentifier}.
82+
*/
4383
public String getIdentifier() {
4484
return identifier;
4585
}

0 commit comments

Comments
 (0)