Module life.expert

Class FileWrappers


  • public final class FileWrappers
    extends java.lang.Object
    The type File helper.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileWrappers()  
    • Method Summary

      Modifier and Type Method Description
      static java.io.File createOrRetrieveFile​(@Nullable java.lang.String file, @Nullable java.nio.file.Path directory)
      Create or retrieve file file.
      static java.util.Optional<java.net.URL> fileToUrl​(@NotNull java.io.File file)
      for using inside streamApi hide exception and return optional
      static <E> java.util.Optional<E> ioOptional​(@Nullable SupplierIO<E> operation)
      Io optional optional.
      static void ioWrapper​(@NotNull RunnableIO operation)
      Io wrapper.
      static void ioWrapper​(@NotNull RunnableIO operation, @NotNull java.lang.String errorMessage)
      Io wrapper.
      static void ioWrapper​(@NotNull RunnableIO operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
      Io wrapper.
      static <E> E ioWrapper​(@NotNull SupplierIO<E> operation)
      Io wrapper e.
      static <E> E ioWrapper​(@NotNull SupplierIO<E> operation, @NotNull java.lang.String errorMessage)
      Io wrapper e.
      static <E> E ioWrapper​(@NotNull SupplierIO<E> operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
      Io wrapper e.
      static <E> void ioWrapper​(E input, @NotNull ConsumerIO<E> operation)
      Io wrapper.
      static <E> void ioWrapper​(E input, @NotNull ConsumerIO<E> operation, @NotNull java.lang.String errorMessage)
      Io wrapper.
      static <E> void ioWrapper​(E input, @NotNull ConsumerIO<E> operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
      Io wrapper.
      static RunnableIO writerWrapper​(@NotNull java.io.File file, @NotNull java.util.function.Supplier<java.lang.String> textToWrite)
      Writer wrapper runnable io.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileWrappers

        public FileWrappers()
    • Method Detail

      • fileToUrl

        public static java.util.Optional<java.net.URL> fileToUrl​(@NotNull
                                                                 @NotNull java.io.File file)
        for using inside streamApi hide exception and return optional
        Parameters:
        file - the file
        Returns:
        the optional
      • createOrRetrieveFile

        public static java.io.File createOrRetrieveFile​(@Nullable
                                                        @Nullable java.lang.String file,
                                                        @Nullable
                                                        @Nullable java.nio.file.Path directory)
        Create or retrieve file file.
        Parameters:
        file - the file
        directory - the directory
        Returns:
        the file
      • ioWrapper

        public static void ioWrapper​(@NotNull
                                     @NotNull RunnableIO operation)
        Io wrapper.
        Parameters:
        operation - the operation
      • ioWrapper

        public static void ioWrapper​(@NotNull
                                     @NotNull RunnableIO operation,
                                     @NotNull
                                     @NotNull java.lang.String errorMessage)
        Io wrapper.
        Parameters:
        operation - the operation
        errorMessage - the error message
      • ioWrapper

        public static void ioWrapper​(@NotNull
                                     @NotNull RunnableIO operation,
                                     @NotNull
                                     @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
        Io wrapper.
        Parameters:
        operation - the operation
        errorMessage - the error message
      • ioWrapper

        public static <E> E ioWrapper​(@NotNull
                                      @NotNull SupplierIO<E> operation)
        Io wrapper e.
        Type Parameters:
        E - the type parameter
        Parameters:
        operation - the operation
        Returns:
        the e
      • ioWrapper

        public static <E> E ioWrapper​(@NotNull
                                      @NotNull SupplierIO<E> operation,
                                      @NotNull
                                      @NotNull java.lang.String errorMessage)
        Io wrapper e.
        Type Parameters:
        E - the type parameter
        Parameters:
        operation - the operation
        errorMessage - the error message
        Returns:
        the e
      • ioWrapper

        public static <E> E ioWrapper​(@NotNull
                                      @NotNull SupplierIO<E> operation,
                                      @NotNull
                                      @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
        Io wrapper e.
        Type Parameters:
        E - the type parameter
        Parameters:
        operation - the operation
        errorMessage - the error message
        Returns:
        the e
      • ioOptional

        public static <E> java.util.Optional<E> ioOptional​(@Nullable
                                                           @Nullable SupplierIO<E> operation)
        Io optional optional.
        Type Parameters:
        E - the type parameter
        Parameters:
        operation - the operation
        Returns:
        the optional
      • ioWrapper

        public static <E> void ioWrapper​(@Nullable
                                         E input,
                                         @NotNull
                                         @NotNull ConsumerIO<E> operation,
                                         @NotNull
                                         @NotNull java.lang.String errorMessage)
        Io wrapper.
        Type Parameters:
        E - the type parameter
        Parameters:
        input - the input
        operation - the operation
        errorMessage - the error message
      • ioWrapper

        public static <E> void ioWrapper​(@Nullable
                                         E input,
                                         @NotNull
                                         @NotNull ConsumerIO<E> operation)
        Io wrapper.
        Type Parameters:
        E - the type parameter
        Parameters:
        input - the input
        operation - the operation
      • ioWrapper

        public static <E> void ioWrapper​(@Nullable
                                         E input,
                                         @NotNull
                                         @NotNull ConsumerIO<E> operation,
                                         @NotNull
                                         @NotNull java.util.function.Supplier<java.lang.String> errorMessage)
        Io wrapper.
        Type Parameters:
        E - the type parameter
        Parameters:
        input - the input
        operation - the operation
        errorMessage - the error message
      • writerWrapper

        public static RunnableIO writerWrapper​(@NotNull
                                               @NotNull java.io.File file,
                                               @NotNull
                                               @NotNull java.util.function.Supplier<java.lang.String> textToWrite)
        Writer wrapper runnable io.
        Parameters:
        file - the file
        textToWrite - the text to write
        Returns:
        the runnable io