Record Class NamespacedKey

java.lang.Object
java.lang.Record
wtf.choco.veinminer.util.NamespacedKey
Record Components:
namespace - the namespace
key - the key

public record NamespacedKey(@NotNull String namespace, @NotNull String key) extends Record
Represents a unique key with a namespace. Keys are under the format namespace:key.
  • Constructor Details

    • NamespacedKey

      public NamespacedKey(@NotNull @NotNull String namespace, @NotNull @NotNull String key)
      Creates an instance of a NamespacedKey record class.
      Parameters:
      namespace - the value for the namespace record component
      key - the value for the key record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • minecraft

      @NotNull public static @NotNull NamespacedKey minecraft(@NotNull @NotNull String key)
      Get a NamespacedKey under the minecraft namespace.
      Parameters:
      key - the key
      Returns:
      the Minecraft namespaced key
    • veinminer

      @NotNull public static @NotNull NamespacedKey veinminer(@NotNull @NotNull String key)
      Get a NamespacedKey under the veinminer namespace.
      Parameters:
      key - the key
      Returns:
      the VeinMiner namespaced key
    • fromString

      @NotNull public static @NotNull NamespacedKey fromString(@NotNull @NotNull String input, @NotNull @NotNull String defaultNamespace)
      Get a NamespacedKey from an input string. If the input does not have a valid namespace, the provided namespace will be used in conjunction with the rest of the key.
      Parameters:
      input - the input string
      defaultNamespace - the namespace to use if none is present in the input string
      Returns:
      the resulting key
    • fromString

      @NotNull public static @NotNull NamespacedKey fromString(@NotNull @NotNull String input)
      Get a NamespacedKey from an input string. If the input does not have a valid namespace, the Minecraft namespace will be used in conjunction with the rest of the key.
      Parameters:
      input - the input string
      Returns:
      the resulting key
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • namespace

      @NotNull public @NotNull String namespace()
      Returns the value of the namespace record component.
      Returns:
      the value of the namespace record component
    • key

      @NotNull public @NotNull String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component