Package org.projectnessie.model
Class Validation
- java.lang.Object
-
- org.projectnessie.model.Validation
-
public final class Validation extends java.lang.ObjectCollection of validation rules.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_CUT_OFF_POLICY_MESSAGEstatic java.util.regex.PatternDEFAULT_CUT_OFF_POLICY_PATTERNstatic java.lang.StringDEFAULT_CUT_OFF_POLICY_REGEXstatic java.lang.StringFORBIDDEN_REF_NAME_MESSAGEstatic java.util.Set<java.lang.String>FORBIDDEN_REF_NAMESstatic java.lang.StringHASH_MESSAGEstatic java.lang.StringHASH_OR_RELATIVE_COMMIT_SPEC_MESSAGEstatic java.util.regex.PatternHASH_OR_RELATIVE_COMMIT_SPEC_PATTERNstatic java.lang.StringHASH_OR_RELATIVE_COMMIT_SPEC_RAW_REGEXRegex 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 java.lang.StringHASH_OR_RELATIVE_COMMIT_SPEC_REGEXstatic java.lang.StringHASH_OR_RELATIVE_COMMIT_SPEC_RULEstatic java.util.regex.PatternHASH_PATTERNstatic java.lang.StringHASH_RAW_REGEXstatic java.lang.StringHASH_REGEXstatic java.lang.StringHASH_RULEstatic java.lang.StringREF_NAME_MESSAGEstatic java.lang.StringREF_NAME_OR_HASH_MESSAGEstatic java.util.regex.PatternREF_NAME_OR_HASH_PATTERNstatic java.lang.StringREF_NAME_OR_HASH_REGEXstatic java.util.regex.PatternREF_NAME_PATH_ELEMENT_PATTERNstatic java.lang.StringREF_NAME_PATH_ELEMENT_REGEXstatic java.lang.StringREF_NAME_PATH_MESSAGEstatic java.util.regex.PatternREF_NAME_PATH_PATTERNstatic java.lang.StringREF_NAME_PATH_REGEXstatic java.util.regex.PatternREF_NAME_PATTERNstatic java.lang.StringREF_NAME_RAW_REGEXstatic java.lang.StringREF_NAME_REGEXstatic java.lang.StringREF_TYPE_MESSAGEstatic java.lang.StringREF_TYPE_RAW_REGEXstatic java.lang.StringREF_TYPE_REGEXstatic java.lang.StringREF_TYPE_RULEstatic java.util.regex.PatternRELATIVE_COMMIT_SPEC_PART_PATTERNstatic java.lang.StringRELATIVE_COMMIT_SPEC_RAW_REGEXstatic java.lang.StringRELATIVE_COMMIT_SPEC_RULE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisForbiddenReferenceName(java.lang.String ref)Checks whetherrefrepresents a forbidden reference name (HEADorDETACHED) or could represent a commit-ID.static booleanisValidHash(java.lang.String hash)Just checks whether a string is a valid hash, but doesn't throw an exception.static booleanisValidHashOrRelativeSpec(java.lang.String hash)Just checks whether a string is a valid hash and/or a relative spec, but doesn't throw an exception.static booleanisValidReferenceName(java.lang.String referenceName)Just checks whether a string is a valid reference-name, but doesn't throw an exception.static booleanisValidReferenceNameOrHash(java.lang.String ref)Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).static voidvalidateDefaultCutOffPolicy(java.lang.String value)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 livestatic java.lang.StringvalidateForbiddenReferenceName(java.lang.String ref)Throws anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).static java.lang.StringvalidateHash(java.lang.String referenceName)Validates whether a string is a valid hash.static java.lang.StringvalidateHashOrRelativeSpec(java.lang.String referenceName)Validates whether a string is a valid hash with optional relative specs.static java.lang.StringvalidateReferenceName(java.lang.String referenceName)Validates whether a string is a valid reference-name.static java.lang.StringvalidateReferenceNameOrHash(java.lang.String ref)Validates whether a string is a valid reference name or hash.
-
-
-
Field Detail
-
HASH_RAW_REGEX
public static final java.lang.String HASH_RAW_REGEX
- See Also:
- Constant Field Values
-
HASH_REGEX
public static final java.lang.String HASH_REGEX
- See Also:
- Constant Field Values
-
RELATIVE_COMMIT_SPEC_RAW_REGEX
public static final java.lang.String RELATIVE_COMMIT_SPEC_RAW_REGEX
- See Also:
- Constant Field Values
-
HASH_OR_RELATIVE_COMMIT_SPEC_RAW_REGEX
public static final java.lang.String 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:
- Constant Field Values
- Lookup by timestamp starts with
-
HASH_OR_RELATIVE_COMMIT_SPEC_REGEX
public static final java.lang.String HASH_OR_RELATIVE_COMMIT_SPEC_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_RAW_REGEX
public static final java.lang.String REF_NAME_RAW_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_REGEX
public static final java.lang.String REF_NAME_REGEX
- See Also:
- Constant Field Values
-
REF_TYPE_RAW_REGEX
public static final java.lang.String REF_TYPE_RAW_REGEX
- See Also:
- Constant Field Values
-
REF_TYPE_REGEX
public static final java.lang.String REF_TYPE_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_REGEX
public static final java.lang.String REF_NAME_OR_HASH_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_PATH_REGEX
public static final java.lang.String REF_NAME_PATH_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_PATH_ELEMENT_REGEX
public static final java.lang.String REF_NAME_PATH_ELEMENT_REGEX
- See Also:
- Constant Field Values
-
HASH_PATTERN
public static final java.util.regex.Pattern HASH_PATTERN
-
REF_NAME_PATTERN
public static final java.util.regex.Pattern REF_NAME_PATTERN
-
RELATIVE_COMMIT_SPEC_PART_PATTERN
public static final java.util.regex.Pattern RELATIVE_COMMIT_SPEC_PART_PATTERN
-
HASH_OR_RELATIVE_COMMIT_SPEC_PATTERN
public static final java.util.regex.Pattern HASH_OR_RELATIVE_COMMIT_SPEC_PATTERN
-
REF_NAME_OR_HASH_PATTERN
public static final java.util.regex.Pattern REF_NAME_OR_HASH_PATTERN
-
REF_NAME_PATH_PATTERN
public static final java.util.regex.Pattern REF_NAME_PATH_PATTERN
-
REF_NAME_PATH_ELEMENT_PATTERN
public static final java.util.regex.Pattern REF_NAME_PATH_ELEMENT_PATTERN
-
DEFAULT_CUT_OFF_POLICY_REGEX
public static final java.lang.String DEFAULT_CUT_OFF_POLICY_REGEX
- See Also:
- Constant Field Values
-
DEFAULT_CUT_OFF_POLICY_MESSAGE
public static final java.lang.String DEFAULT_CUT_OFF_POLICY_MESSAGE
- See Also:
- Constant Field Values
-
DEFAULT_CUT_OFF_POLICY_PATTERN
public static final java.util.regex.Pattern DEFAULT_CUT_OFF_POLICY_PATTERN
-
HASH_RULE
public static final java.lang.String HASH_RULE
- See Also:
- Constant Field Values
-
HASH_MESSAGE
public static final java.lang.String HASH_MESSAGE
- See Also:
- Constant Field Values
-
RELATIVE_COMMIT_SPEC_RULE
public static final java.lang.String RELATIVE_COMMIT_SPEC_RULE
- See Also:
- Constant Field Values
-
HASH_OR_RELATIVE_COMMIT_SPEC_RULE
public static final java.lang.String HASH_OR_RELATIVE_COMMIT_SPEC_RULE
- See Also:
- Constant Field Values
-
HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE
public static final java.lang.String HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_PATH_MESSAGE
public static final java.lang.String REF_NAME_PATH_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_MESSAGE
public static final java.lang.String REF_NAME_MESSAGE
- See Also:
- Constant Field Values
-
REF_TYPE_RULE
public static final java.lang.String REF_TYPE_RULE
- See Also:
- Constant Field Values
-
REF_TYPE_MESSAGE
public static final java.lang.String REF_TYPE_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_MESSAGE
public static final java.lang.String REF_NAME_OR_HASH_MESSAGE
- See Also:
- Constant Field Values
-
FORBIDDEN_REF_NAME_MESSAGE
public static final java.lang.String FORBIDDEN_REF_NAME_MESSAGE
- See Also:
- Constant Field Values
-
FORBIDDEN_REF_NAMES
public static final java.util.Set<java.lang.String> FORBIDDEN_REF_NAMES
-
-
Method Detail
-
isValidReferenceName
public static boolean isValidReferenceName(java.lang.String referenceName)
Just checks whether a string is a valid reference-name, but doesn't throw an exception.- See Also:
validateReferenceName(String)
-
isValidHash
public static boolean isValidHash(java.lang.String hash)
Just checks whether a string is a valid hash, but doesn't throw an exception.- See Also:
validateHash(String)
-
isValidHashOrRelativeSpec
public static boolean isValidHashOrRelativeSpec(java.lang.String hash)
Just checks whether a string is a valid hash and/or a relative spec, but doesn't throw an exception.- See Also:
validateHashOrRelativeSpec(String)
-
isValidReferenceNameOrHash
public static boolean isValidReferenceNameOrHash(java.lang.String ref)
Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).
-
validateReferenceName
public static java.lang.String validateReferenceName(java.lang.String referenceName) throws java.lang.IllegalArgumentExceptionValidates 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:
java.lang.IllegalArgumentException
-
validateHash
public static java.lang.String validateHash(java.lang.String referenceName) throws java.lang.IllegalArgumentExceptionValidates 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:
java.lang.IllegalArgumentException
-
validateHashOrRelativeSpec
public static java.lang.String validateHashOrRelativeSpec(java.lang.String referenceName) throws java.lang.IllegalArgumentExceptionValidates whether a string is a valid hash with optional relative specs.- Parameters:
referenceName- the reference name string to test.- Throws:
java.lang.IllegalArgumentException
-
validateDefaultCutOffPolicy
public static void validateDefaultCutOffPolicy(java.lang.String value)
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
public static java.lang.String validateReferenceNameOrHash(java.lang.String ref) throws java.lang.IllegalArgumentExceptionValidates 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:
java.lang.IllegalArgumentException
-
isForbiddenReferenceName
public static boolean isForbiddenReferenceName(java.lang.String ref)
Checks whetherrefrepresents a forbidden reference name (HEADorDETACHED) or could represent a commit-ID.- Parameters:
ref- reference name to check- Returns:
true, if forbidden
-
validateForbiddenReferenceName
public static java.lang.String validateForbiddenReferenceName(java.lang.String ref) throws java.lang.IllegalArgumentExceptionThrows anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).- Parameters:
ref- reference name to check- Returns:
ref- Throws:
java.lang.IllegalArgumentException
-
-