Class IOGuard


  • public final class IOGuard
    extends Object
    Allows to perform "unsafe" IO operations on read-only node.
    The one who uses the class should be sure that the use of restricted operations is safe.
    Since:
    2020.1
    • Method Detail

      • allowDiskWrite

        public static <E extends Exception> void allowDiskWrite​(@NotNull
                                                                ActionThrow<E> action)
                                                         throws E extends Exception
        Code that wants to execute file write operation should be wrapped to this method.
        Type Parameters:
        E - type of exception that the action could throw
        Parameters:
        action - action to execute
        Throws:
        E - exception if the action throws an exception
        E extends Exception
      • allowDiskWrite

        public static <R,​E extends Exception> R allowDiskWrite​(@NotNull
                                                                     FuncThrow<R,​E> function)
                                                              throws E extends Exception
        Code that wants to execute file write operation should be wrapped to this method.
        Type Parameters:
        R - type of the function result
        E - type of exception that the function could throw
        Parameters:
        function - function to execute
        Returns:
        function result
        Throws:
        E - exception if the function throws an exception
        E extends Exception
      • allowNetworkCall

        public static <E extends Exception> void allowNetworkCall​(@NotNull
                                                                  ActionThrow<E> action)
                                                           throws E extends Exception
        Code that wants to call network operation should be wrapped to this method.
        Type Parameters:
        E - type of exception that the action could throw
        Parameters:
        action - action to execute
        Throws:
        E - exception if the action throws an exception
        E extends Exception
      • allowNetworkCall

        public static <R,​E extends Exception> R allowNetworkCall​(@NotNull
                                                                       FuncThrow<R,​E> function)
                                                                throws E extends Exception
        Code that wants to call network operation should be wrapped to this method.
        Type Parameters:
        R - type of the function result
        E - type of exception that the function could throw
        Parameters:
        function - function to execute
        Returns:
        function result
        Throws:
        E - exception if the function throws an exception
        E extends Exception
      • allowCommandLine

        public static <E extends Exception> void allowCommandLine​(@NotNull
                                                                  ActionThrow<E> action)
                                                           throws E extends Exception
        Code that wants to run command line process should be wrapped to this method.
        Type Parameters:
        E - type of exception that the action could throw
        Parameters:
        action - action to execute
        Throws:
        E - exception if the action throws an exception
        E extends Exception
      • allowCommandLine

        public static <R,​E extends Exception> R allowCommandLine​(@NotNull
                                                                       FuncThrow<R,​E> function)
                                                                throws E extends Exception
        Code that wants to run command line process should be wrapped to this method.
        Type Parameters:
        R - type of the function result
        E - type of exception that the function could throw
        Parameters:
        function - function to execute
        Returns:
        function result
        Throws:
        E - exception if the function throws an exception
        E extends Exception
      • allowNetworkAndCommandLine

        public static <E extends Exception> void allowNetworkAndCommandLine​(@NotNull
                                                                            ActionThrow<E> action)
                                                                     throws E extends Exception
        Code that wants to run both network call and command line process should be wrapped to this method.
        Type Parameters:
        E - type of exception that the action could throw
        Parameters:
        action - action to execute
        Throws:
        E - exception if the action throws an exception
        E extends Exception
      • allowNetworkAndCommandLine

        public static <R,​E extends Exception> R allowNetworkAndCommandLine​(@NotNull
                                                                                 FuncThrow<R,​E> function)
                                                                          throws E extends Exception
        Code that wants to run both network call and command line process should be wrapped to this method.
        Type Parameters:
        R - type of the function result
        E - type of exception that the function could throw
        Parameters:
        function - function to execute
        Returns:
        function result
        Throws:
        E - exception if the function throws an exception
        E extends Exception