Package org.projectnessie.model
Class ContentKey
- java.lang.Object
-
- org.projectnessie.model.ContentKey
-
- All Implemented Interfaces:
java.lang.Comparable<ContentKey>
@Immutable public abstract class ContentKey extends java.lang.Object implements java.lang.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 Summary
Fields Modifier and Type Field Description static intMAX_ELEMENTSMaximum number of elements.static intMAX_LENGTHMaximum number of characters in a key.
-
Constructor Summary
Constructors Constructor Description ContentKey()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(ContentKey that)static ContentKeyfromPathString(java.lang.String encoded)Convert from path encoded string to normal string.intgetElementCount()abstract @NotNull @NotNull @Size @Size(min=1) java.util.List<java.lang.String>getElements()java.lang.String[]getElementsArray()java.lang.StringgetName()NamespacegetNamespace()Returns the namespace that is always consisting of the first N-1 elements fromgetElements().ContentKeygetParent()inthashCode()static ContentKeyof(java.lang.String... elements)static ContentKeyof(java.util.List<java.lang.String> elements)static ContentKeyof(Namespace namespace, java.lang.String name)booleanstartsWith(ContentKey other)booleanstartsWith(Namespace other)java.lang.StringtoPathString()Convert this key to a url encoded path string.java.lang.StringtoString()ContentKeytruncateToLength(int targetMaxLength)Return the content key, truncated to the given maximum length if the number of elements is greater thantargetMaxLength, otherwise returns this content key.protected voidvalidate()
-
-
-
Field Detail
-
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:
- Constant Field Values
-
MAX_ELEMENTS
public static final int MAX_ELEMENTS
Maximum number of elements.- See Also:
- Constant Field Values
-
-
Method Detail
-
getElements
@NotNull @NotNull @Size @Size(min=1) @Parameter(order=1) public abstract @NotNull @NotNull @Size @Size(min=1) java.util.List<java.lang.String> getElements()
-
getElementsArray
@Redacted public java.lang.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 fromgetElements().- Returns:
- A
Namespaceinstance that is always consisting of the first N-1 elements fromgetElements().
-
getName
@Redacted public java.lang.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 thantargetMaxLength, otherwise returns this content key.
-
startsWith
public boolean startsWith(ContentKey other)
-
startsWith
public boolean startsWith(Namespace other)
-
of
public static ContentKey of(Namespace namespace, java.lang.String name)
-
of
public static ContentKey of(java.lang.String... elements)
-
of
public static ContentKey of(java.util.List<java.lang.String> elements)
-
validate
@Check protected void validate()
-
fromPathString
public static ContentKey fromPathString(java.lang.String encoded)
Convert from path encoded string to normal string.- Parameters:
encoded- Path encoded string- Returns:
- Actual key.
-
toPathString
public java.lang.String toPathString()
Convert this key to a url encoded path string.- Returns:
- String encoded for path use.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public final int compareTo(ContentKey that)
- Specified by:
compareToin interfacejava.lang.Comparable<ContentKey>
-
-