Package org.projectnessie.model
Class Validation
java.lang.Object
org.projectnessie.model.Validation
Collection of validation rules.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Patternstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Patternstatic final StringRegex with an optional hash and a sequence of relative lookups, which can be by-timestamp, by-n-th-predecessor or by-n-th-parent.static final Stringstatic final Stringstatic final Patternstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Patternstatic final Stringstatic final Patternstatic final Stringstatic final Stringstatic final Patternstatic final Stringstatic final Patternstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Patternstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whetherrefrepresents a forbidden reference name (HEADorDETACHED) or could represent a commit-ID.static booleanisValidHash(String hash) Just checks whether a string is a valid hash, but doesn't throw an exception.static booleanJust checks whether a string is a valid hash and/or a relative spec, but doesn't throw an exception.static booleanisValidReferenceName(String referenceName) Just checks whether a string is a valid reference-name, but doesn't throw an exception.static booleanJust checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).static voidValidate default cutoff policy.Policies can be one of: - number of commits as an integer value, - a duration (see java.time.Duration), - an ISO instant, - 'NONE,' means everything's considered as livestatic StringThrows anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).static StringvalidateHash(String referenceName) Validates whether a string is a valid hash.static StringvalidateHashOrRelativeSpec(String referenceName) Validates whether a string is a valid hash with optional relative specs.static StringvalidateReferenceName(String referenceName) Validates whether a string is a valid reference-name.static StringValidates whether a string is a valid reference name or hash.
-
Field Details
-
HASH_RAW_REGEX
- See Also:
-
HASH_REGEX
- See Also:
-
RELATIVE_COMMIT_SPEC_RAW_REGEX
- See Also:
-
HASH_OR_RELATIVE_COMMIT_SPEC_RAW_REGEX
Regex with an optional hash and a sequence of relative lookups, which can be by-timestamp, by-n-th-predecessor or by-n-th-parent.- Lookup by timestamp starts with
*followed by the numeric value of the timestamp in milliseconds since epoch. - Lookup by n-th predecessor starts with
~followed by the value for the n-th commit in the commit log. - Lookup by n-th parent starts with
^followed by either 1, referencing the direct parent, or 2, referencing the merge parent.
Valid values are:
11223344~10-> the 10th parent of the commit1122334411223344^2-> the merge parent of the commit1122334411223344~10^2-> the merge parent of the 10th parent of the commit1122334411223344~10^1-> the direct parent of the 10th parent of the commit11223344- functionally equal to11223344~1111223344*10000000000-> the commit in the commit log starting at11223344with a commit-created timestamp of10000000000or less.11223344*2021-04-07T14:42:25.534748Z-> the commit in the commit log starting at11223344with a commit-created timestamp of2021-04-07T14:42:25.534748Zor less.
- See Also:
- Lookup by timestamp starts with
-
HASH_OR_RELATIVE_COMMIT_SPEC_REGEX
- See Also:
-
REF_NAME_RAW_REGEX
- See Also:
-
REF_NAME_REGEX
- See Also:
-
REF_TYPE_RAW_REGEX
- See Also:
-
REF_TYPE_REGEX
- See Also:
-
REF_NAME_OR_HASH_REGEX
- See Also:
-
REF_NAME_PATH_REGEX
- See Also:
-
REF_NAME_PATH_ELEMENT_REGEX
- See Also:
-
HASH_PATTERN
-
REF_NAME_PATTERN
-
RELATIVE_COMMIT_SPEC_PART_PATTERN
-
HASH_OR_RELATIVE_COMMIT_SPEC_PATTERN
-
REF_NAME_OR_HASH_PATTERN
-
REF_NAME_PATH_PATTERN
-
REF_NAME_PATH_ELEMENT_PATTERN
-
DEFAULT_CUT_OFF_POLICY_REGEX
- See Also:
-
DEFAULT_CUT_OFF_POLICY_MESSAGE
- See Also:
-
DEFAULT_CUT_OFF_POLICY_PATTERN
-
HASH_RULE
- See Also:
-
HASH_MESSAGE
- See Also:
-
RELATIVE_COMMIT_SPEC_RULE
- See Also:
-
HASH_OR_RELATIVE_COMMIT_SPEC_RULE
- See Also:
-
HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE
- See Also:
-
REF_NAME_PATH_MESSAGE
- See Also:
-
REF_NAME_MESSAGE
- See Also:
-
REF_TYPE_RULE
- See Also:
-
REF_TYPE_MESSAGE
- See Also:
-
REF_NAME_OR_HASH_MESSAGE
- See Also:
-
FORBIDDEN_REF_NAME_MESSAGE
- See Also:
-
FORBIDDEN_REF_NAMES
-
-
Method Details
-
isValidReferenceName
Just checks whether a string is a valid reference-name, but doesn't throw an exception.- See Also:
-
isValidHash
Just checks whether a string is a valid hash, but doesn't throw an exception.- See Also:
-
isValidHashOrRelativeSpec
Just checks whether a string is a valid hash and/or a relative spec, but doesn't throw an exception.- See Also:
-
isValidReferenceNameOrHash
Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)). -
validateReferenceName
Validates whether a string is a valid reference-name.The rules are: "start with a letter, followed by letters, digits, one of the ./_- characters, not end with a slash or dot, not contain \'..\'"
- Parameters:
referenceName- the reference name string to test.- Throws:
IllegalArgumentException
-
validateHash
Validates whether a string is a valid hash.The rules are: "consist of the hex representation of 4-32 bytes"
- Parameters:
referenceName- the reference name string to test.- Throws:
IllegalArgumentException
-
validateHashOrRelativeSpec
public static String validateHashOrRelativeSpec(String referenceName) throws IllegalArgumentException Validates whether a string is a valid hash with optional relative specs.- Parameters:
referenceName- the reference name string to test.- Throws:
IllegalArgumentException
-
validateDefaultCutOffPolicy
Validate default cutoff policy.Policies can be one of: - number of commits as an integer value, - a duration (see java.time.Duration), - an ISO instant, - 'NONE,' means everything's considered as live -
validateReferenceNameOrHash
Validates whether a string is a valid reference name or hash.See
validateReferenceName(String)andvalidateHash(String)for the rules.- Parameters:
ref- the reference name string to test.- Throws:
IllegalArgumentException
-
isForbiddenReferenceName
Checks whetherrefrepresents a forbidden reference name (HEADorDETACHED) or could represent a commit-ID.- Parameters:
ref- reference name to check- Returns:
true, if forbidden
-
validateForbiddenReferenceName
Throws anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).- Parameters:
ref- reference name to check- Returns:
ref- Throws:
IllegalArgumentException
-