Class GenericUtils


  • public final class GenericUtils
    extends java.lang.Object

    Class with generic utilities.

    Project:

    Library for the integration with the services of @Firma, eVisor and TS@.

    Version:
    1.3, 18/04/2022.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean assertArrayValid​(byte[] data)
      Asserts whether a array is valid (not null and not empty).
      static boolean assertStringValue​(java.lang.String value)
      Asserts whether a value is valid (not null or not empty).
      static boolean checkNullValues​(java.lang.Object... values)
      Checks if a value is null.
      static byte[] getDataFromInputStream​(java.io.InputStream input)
      Reads and converts a bytes stream to byte array.
      static java.lang.String getValueFromMapsTree​(java.lang.String path, java.util.Map<java.lang.String,​java.lang.Object> treeValues)
      Retrieves a value from a tree of several maps by a path given.
      static void printResult​(byte[] result, Logger logger)
      Prints the resulting data in base64 format.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assertStringValue

        public static boolean assertStringValue​(java.lang.String value)
        Asserts whether a value is valid (not null or not empty).
        Parameters:
        value - string to validate.
        Returns:
        true if string is valid and false otherwise.
      • assertArrayValid

        public static boolean assertArrayValid​(byte[] data)
        Asserts whether a array is valid (not null and not empty).
        Parameters:
        data - array to validate.
        Returns:
        true if array is valid and false otherwise.
      • getValueFromMapsTree

        public static java.lang.String getValueFromMapsTree​(java.lang.String path,
                                                            java.util.Map<java.lang.String,​java.lang.Object> treeValues)
        Retrieves a value from a tree of several maps by a path given.
        Parameters:
        path - path of maps tree separated by '/'.
        treeValues - collection of maps (type: Map<String, Object\>).
        Returns:
        value of the key requested.
      • getDataFromInputStream

        public static byte[] getDataFromInputStream​(java.io.InputStream input)
                                             throws java.io.IOException
        Reads and converts a bytes stream to byte array.
        Parameters:
        input - input stream to convert.
        Returns:
        byte array with data.
        Throws:
        java.io.IOException - If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
      • checkNullValues

        public static boolean checkNullValues​(java.lang.Object... values)
        Checks if a value is null.
        Parameters:
        values - collection of values to validate.
        Returns:
        true if any parameter is null and false if all parameters are valid (not null).
      • printResult

        public static void printResult​(byte[] result,
                                       Logger logger)
        Prints the resulting data in base64 format.
        Parameters:
        result - result bytes.
        logger - logger object used for print.