Class ValidatorUtils

java.lang.Object
com.csse3200.game.cutscene.validators.ValidatorUtils

public class ValidatorUtils extends Object
  • Constructor Details

    • ValidatorUtils

      public ValidatorUtils()
  • Method Details

    • stringMapValid

      public static boolean stringMapValid(Map<String,String> map)
      Validates a Map<String,String> against the following rules:
      Parameters:
      map - The Map<String,String>
      Returns:
      false if any key or value is invalid, true otherwise (The whole map is valid)
    • validateTransition

      public static List<AuthoringError> validateTransition(String beatId, ActionDTO action)
      Takes a beatId string and ActionDTO and validates that a valid transition is present in the ActionDTO

      The conditions for a valid transition are as follows:

      • The transition field value must be a string
      • The transition field value must be in Transition.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 processed
      action - The ActionDTO that the transition is contained in
      Returns:
      A list of AuthoringError detailing each rule infraction
    • validateString

      public static List<AuthoringError> validateString(Object object, String key, String path)
      Validates a java Object to see if it's a valid String object.

      It checks that:

      Parameters:
      object - The alleged string object to be validated
      key - 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

      public static List<AuthoringError> validateInt(Object object, String key, String path)
      Validates a java Object to see if it's a valid Integer or Long object.

      It checks that:

      Parameters:
      object - The alleged string object to be validated
      key - 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

      public static List<AuthoringError> validateFloatDouble(Object object, String key, String path)
      Validates a java Object to see if it's a valid Float or Double object.

      It checks that:

      Parameters:
      object - The alleged string object to be validated
      key - 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 java Object to see if it's a valid Float or Double If it is a valid Float or Double, it then converts it to a double and checks if it's in the specified range.
      Parameters:
      object - The alleged string object to be validated
      key - The key for error (used for tracing)
      path - The path of the error (used for tracing)
      min - The minimum bound for the double
      max - The maximum bound for the double
      Returns:
      A list of AuthoringError detailing each rule infraction
    • validateBool

      public static List<AuthoringError> validateBool(Object object, String key, String path)
      Validates a java Object to see if it's a valid Boolean object.

      It checks that:

      Parameters:
      object - The alleged string object to be validated
      key - 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)
      Validates that a Comparable Number is within the inclusive range [min, max].
      Type Parameters:
      N - Numeric type that is Number and Comparable to itself
      Parameters:
      number - The Comparable Number that is going to be checked.
      min - The minimum bound
      max - The maximum bound
      path - The path of the error (used for tracing)
      Returns:
      A list of AuthoringError detailing each rule infraction
    • validateAwait

      public static List<AuthoringError> validateAwait(String beatId, ActionDTO action)
      Takes a beatId string and ActionDTO and validates that a valid await is present in the ActionDTO For a valid await, the ActionDTO must contain a valid boolean value under the tag "await"
      Parameters:
      beatId - The string id of the beat being processed
      action - The ActionDTO 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 a beatId string and ActionDTO and validates that a valid sound ID is present in the ActionDTO For a valid soundID, the ActionDTO must contain a valid string value under the tag "await" AND the value of the field must be in the ValidationCtx.soundIds().
      Parameters:
      action - The ActionDTO that the transition is contained in
      context - The ValidationCtx with the document context
      path - The path of the error (used for tracing)
      Returns:
      A list of AuthoringError detailing each rule infraction