com.atlassian.fisheye.util
Enum FieldValidator

java.lang.Object
  extended by java.lang.Enum<FieldValidator>
      extended by com.atlassian.fisheye.util.FieldValidator
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<FieldValidator>

public enum FieldValidator
extends java.lang.Enum<FieldValidator>

Utility class for validating field. All validation methods throw an IllegalArgumentException if the provided value does not pass validation.

Author:
mheemskerk

Enum Constant Summary
INSTANCE
           
 
Method Summary
 void notBlank(java.lang.String fieldname, java.lang.String value)
          Validates that value is not blank
 void positive(java.lang.String fieldname, java.lang.Float value)
          Validates that value is not positive
 void positive(java.lang.String fieldname, java.lang.Integer value)
          Validates that value is positive
 void positive(java.lang.String fieldname, java.lang.Long value)
          Validates that value is positive
 void validTimeString(java.lang.String fieldname, java.lang.String timeString)
          Validates that value is a valid time string.
static FieldValidator valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static FieldValidator[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

INSTANCE

public static final FieldValidator INSTANCE
Method Detail

values

public static FieldValidator[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (FieldValidator c : FieldValidator.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static FieldValidator valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

notBlank

public void notBlank(java.lang.String fieldname,
                     java.lang.String value)
Validates that value is not blank

Parameters:
fieldname - the name of the field that is validated. This is used in the exception message.
value - the value to validate

positive

public void positive(java.lang.String fieldname,
                     java.lang.Integer value)
Validates that value is positive

Parameters:
fieldname - the name of the field that is validated. This is used in the exception message.
value - the value to validate

positive

public void positive(java.lang.String fieldname,
                     java.lang.Float value)
Validates that value is not positive

Parameters:
fieldname - the name of the field that is validated. This is used in the exception message.
value - the value to validate

positive

public void positive(java.lang.String fieldname,
                     java.lang.Long value)
Validates that value is positive

Parameters:
fieldname - the name of the field that is validated. This is used in the exception message.
value - the value to validate

validTimeString

public void validTimeString(java.lang.String fieldname,
                            java.lang.String timeString)
Validates that value is a valid time string. A valid time string is a number followed by the unit of time. The following units can be used: s|second|seconds|mi|minute|minutes|h|hour|hours|d|day|days|w|week|weeks|mo|month|months|y|year|years

Parameters:
fieldname - the name of the field that is validated. This is used in the exception message.
timeString - the value to validate