Class ValidatorUtils
java.lang.Object
com.csse3200.game.cutscene.validators.ValidatorUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
stringMapValid
(Map<String, String> map) Validates aMap<String,
against the following rules: For each map entryString> Map.Entry
:Map.Entry.getKey()
must not be nullMap.Entry.getKey()
must not be emptyMap.Entry.getValue()
must not be nullMap.Entry.getValue()
must not be emptystatic List
<AuthoringError> validateAwait
(String beatId, ActionDTO action) static List
<AuthoringError> validateBool
(Object object, String key, String path) static List
<AuthoringError> validateDoubleWithRange
(Object object, String key, String path, double min, double max) static List
<AuthoringError> validateFloatDouble
(Object object, String key, String path) static List
<AuthoringError> validateInt
(Object object, String key, String path) static <N extends Number & Comparable<N>>
List<AuthoringError> validateRange
(N number, N min, N max, String path) static List
<AuthoringError> validateSoundId
(ActionDTO action, ValidationCtx context, String path) Takes abeatId
string andActionDTO
and validates that a valid sound ID is present in theActionDTO
For a valid soundID, theActionDTO
must contain a valid string value under the tag"await"
AND the value of the field must be in theValidationCtx.soundIds()
.static List
<AuthoringError> validateString
(Object object, String key, String path) static List
<AuthoringError> validateTransition
(String beatId, ActionDTO action)
-
Constructor Details
-
ValidatorUtils
public ValidatorUtils()
-
-
Method Details
-
stringMapValid
Validates aMap<String,
against the following rules:String> - For each map entry
Map.Entry
:Map.Entry.getKey()
must not be nullMap.Entry.getKey()
must not be emptyMap.Entry.getValue()
must not be nullMap.Entry.getValue()
must not be empty
- For each map entry
-
validateTransition
Takes abeatId
string andActionDTO
and validates that a valid transition is present in theActionDTO
The conditions for a valid transition are as follows:
- The
transition
field value must be a string - The
transition
field value must be inTransition.displayNames()
- The
duration
field value must be an integer - The
duration
field value must be>0
- Parameters:
beatId
- The string id of the beat being processedaction
- TheActionDTO
that the transition is contained in- Returns:
- A list of
AuthoringError
detailing each rule infraction
- The
-
validateString
- Parameters:
object
- The alleged string object to be validatedkey
- The key for error (used for tracing)path
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateInt
- Parameters:
object
- The alleged string object to be validatedkey
- The key for error (used for tracing)path
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateFloatDouble
- Parameters:
object
- The alleged string object to be validatedkey
- The key for error (used for tracing)path
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateDoubleWithRange
public static List<AuthoringError> validateDoubleWithRange(Object object, String key, String path, double min, double max) Validates a javaObject
to see if it's a validFloat
orDouble
If it is a validFloat
orDouble
, it then converts it to a double and checks if it's in the specified range.- Parameters:
object
- The alleged string object to be validatedkey
- The key for error (used for tracing)path
- The path of the error (used for tracing)min
- The minimum bound for the doublemax
- The maximum bound for the double- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateBool
- Parameters:
object
- The alleged string object to be validatedkey
- The key for error (used for tracing)path
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateRange
public static <N extends Number & Comparable<N>> List<AuthoringError> validateRange(N number, N min, N max, String path) - Type Parameters:
N
- Numeric type that isNumber
andComparable
to itself- Parameters:
number
- TheComparable
Number
that is going to be checked.min
- The minimum boundmax
- The maximum boundpath
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateAwait
Takes abeatId
string andActionDTO
and validates that a valid await is present in theActionDTO
For a valid await, theActionDTO
must contain a valid boolean value under the tag"await"
- Parameters:
beatId
- The string id of the beat being processedaction
- TheActionDTO
that the transition is contained in- Returns:
- A list of
AuthoringError
detailing each rule infraction
-
validateSoundId
public static List<AuthoringError> validateSoundId(ActionDTO action, ValidationCtx context, String path) Takes abeatId
string andActionDTO
and validates that a valid sound ID is present in theActionDTO
For a valid soundID, theActionDTO
must contain a valid string value under the tag"await"
AND the value of the field must be in theValidationCtx.soundIds()
.- Parameters:
action
- TheActionDTO
that the transition is contained incontext
- TheValidationCtx
with the document contextpath
- The path of the error (used for tracing)- Returns:
- A list of
AuthoringError
detailing each rule infraction
-