Class ContentKey

java.lang.Object
org.projectnessie.model.ContentKey
All Implemented Interfaces:
Comparable<ContentKey>

@Immutable public abstract class ContentKey extends Object implements Comparable<ContentKey>
Key for the content of an object.

For URL encoding, embedded periods within a segment are replaced with zero byte values before passing in a url string.

  • Field Details

    • MAX_LENGTH

      public static final int MAX_LENGTH
      Maximum number of characters in a key. Note: characters can take up to 3 bytes via UTF-8.
      See Also:
    • MAX_ELEMENTS

      public static final int MAX_ELEMENTS
      Maximum number of elements.
      See Also:
  • Constructor Details

    • ContentKey

      public ContentKey()
  • Method Details

    • getElements

      @NotNull @NotNull @Size @Size(min=1) @Parameter(order=1) public abstract @NotNull @NotNull @Size @Size(min=1) List<String> getElements()
    • getElementsArray

      @Redacted public String[] getElementsArray()
    • getElementCount

      @Redacted public int getElementCount()
    • getNamespace

      @Redacted public Namespace getNamespace()
      Returns the namespace that is always consisting of the first N-1 elements from getElements().
      Returns:
      A Namespace instance that is always consisting of the first N-1 elements from getElements().
    • getName

      @Redacted public String getName()
    • getParent

      @Redacted public ContentKey getParent()
    • truncateToLength

      public ContentKey truncateToLength(int targetMaxLength)
      Return the content key, truncated to the given maximum length if the number of elements is greater than targetMaxLength, otherwise returns this content key.
    • startsWith

      public boolean startsWith(ContentKey other)
    • startsWith

      public boolean startsWith(Namespace other)
    • of

      public static ContentKey of(Namespace namespace, String name)
    • of

      public static ContentKey of(String... elements)
    • of

      public static ContentKey of(List<String> elements)
    • validate

      @Check protected void validate()
    • fromPathString

      public static ContentKey fromPathString(String encoded)
      Convert from path encoded string to normal string.
      Parameters:
      encoded - Path encoded string
      Returns:
      Actual key.
    • toPathString

      public String toPathString()
      Convert this key to a url encoded path string.
      Returns:
      String encoded for path use.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public final int compareTo(ContentKey that)
      Specified by:
      compareTo in interface Comparable<ContentKey>