Class Nd4jCommonValidator


  • public class Nd4jCommonValidator
    extends Object
    • Method Detail

      • isValidFile

        public static ValidationResult isValidFile​(@NonNull
                                                   @NonNull File f)
        Validate whether the specified file is a valid file (must exist and be non-empty)
        Parameters:
        f - File to check
        Returns:
        Result of validation
      • isValidFile

        public static ValidationResult isValidFile​(@NonNull
                                                   @NonNull File f,
                                                   String formatType,
                                                   boolean allowEmpty)
        Validate whether the specified file is a valid file
        Parameters:
        f - File to check
        formatType - Name of the file format to include in validation results
        allowEmpty - If true: allow empty files to pass. False: empty files will fail validation
        Returns:
        Result of validation
      • isValidJson

        public static ValidationResult isValidJson​(@NonNull
                                                   @NonNull File f,
                                                   Charset charset)
        Validate whether the specified file is a valid JSON file. Note that this does not match the JSON content against a specific schema
        Parameters:
        f - File to check
        charset - Character set for file
        Returns:
        Result of validation
      • isValidJSON

        public static ValidationResult isValidJSON​(String s)
        Validate whether the specified String is valid JSON. Note that this does not match the JSON content against a specific schema
        Parameters:
        s - JSON String to check
        Returns:
        Result of validation
      • isValidZipFile

        public static ValidationResult isValidZipFile​(@NonNull
                                                      @NonNull File f,
                                                      boolean allowEmpty)
        Validate whether the specified file is a valid Zip file
        Parameters:
        f - File to check
        allowEmpty - If true: allow empty zip files to pass validation. False: empty zip files will fail validation.
        Returns:
        Result of validation
      • isValidZipFile

        public static ValidationResult isValidZipFile​(@NonNull
                                                      @NonNull File f,
                                                      boolean allowEmpty,
                                                      String... requiredEntries)
        Validate whether the specified file is a valid Zip file
        Parameters:
        f - File to check
        allowEmpty - If true: allow empty zip files to pass validation. False: empty zip files will fail validation.
        Returns:
        Result of validation
      • isValidZipFile

        public static ValidationResult isValidZipFile​(@NonNull
                                                      @NonNull File f,
                                                      boolean allowEmpty,
                                                      List<String> requiredEntries)
        Validate whether the specified file is a valid Zip file, and contains all of the required entries
        Parameters:
        f - File to check
        allowEmpty - If true: allow empty zip files to pass validation. False: empty zip files will fail validation.
        requiredEntries - If non-null, all of the specified entries must be present for the file to pass validation
        Returns:
        Result of validation
      • getPath

        public static String getPath​(File f)
        Null-safe and "no absolute path exists" safe method for getting the path of a file for validation purposes