Package org.projectnessie.model
Class Validation
- java.lang.Object
-
- org.projectnessie.model.Validation
-
public final class Validation extends Object
Collection of validation rules.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORBIDDEN_REF_NAME_MESSAGEstatic Set<String>FORBIDDEN_REF_NAMESstatic StringHASH_MESSAGEstatic PatternHASH_PATTERNstatic StringHASH_RAW_REGEXstatic StringHASH_REGEXstatic StringREF_NAME_MESSAGEstatic StringREF_NAME_OR_HASH_MESSAGEstatic PatternREF_NAME_OR_HASH_PATTERNstatic StringREF_NAME_OR_HASH_REGEXstatic PatternREF_NAME_PATTERNstatic StringREF_NAME_RAW_REGEXstatic StringREF_NAME_REGEX
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisForbiddenReferenceName(String ref)Checks 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 booleanisValidReferenceName(String referenceName)Just checks whether a string is a valid reference-name, but doesn't throw an exception.static booleanisValidReferenceNameOrHash(String ref)Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).static StringvalidateForbiddenReferenceName(String ref)Throws anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).static StringvalidateHash(String referenceName)Validates whether a string is a valid hash.static StringvalidateReferenceName(String referenceName)Validates whether a string is a valid reference-name.static StringvalidateReferenceNameOrHash(String ref)Validates whether a string is a valid reference name or hash.
-
-
-
Field Detail
-
HASH_RAW_REGEX
public static final String HASH_RAW_REGEX
- See Also:
- Constant Field Values
-
HASH_REGEX
public static final String HASH_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_RAW_REGEX
public static final String REF_NAME_RAW_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_REGEX
public static final String REF_NAME_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_REGEX
public static final String REF_NAME_OR_HASH_REGEX
- See Also:
- Constant Field Values
-
HASH_PATTERN
public static final Pattern HASH_PATTERN
-
REF_NAME_PATTERN
public static final Pattern REF_NAME_PATTERN
-
REF_NAME_OR_HASH_PATTERN
public static final Pattern REF_NAME_OR_HASH_PATTERN
-
HASH_MESSAGE
public static final String HASH_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_MESSAGE
public static final String REF_NAME_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_MESSAGE
public static final String REF_NAME_OR_HASH_MESSAGE
- See Also:
- Constant Field Values
-
FORBIDDEN_REF_NAME_MESSAGE
public static final String FORBIDDEN_REF_NAME_MESSAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isValidReferenceName
public static boolean isValidReferenceName(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(String hash)
Just checks whether a string is a valid hash, but doesn't throw an exception.- See Also:
validateHash(String)
-
isValidReferenceNameOrHash
public static boolean isValidReferenceNameOrHash(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 String validateReferenceName(String referenceName) throws IllegalArgumentException
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
public static String validateHash(String referenceName) throws IllegalArgumentException
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
-
validateReferenceNameOrHash
public static String validateReferenceNameOrHash(String ref) throws IllegalArgumentException
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
public static boolean isForbiddenReferenceName(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 String validateForbiddenReferenceName(String ref) throws IllegalArgumentException
Throws anIllegalArgumentExceptionifrefrepresents a forbidden reference name, seeisForbiddenReferenceName(String).- Parameters:
ref- reference name to check- Returns:
ref- Throws:
IllegalArgumentException
-
-