Class FileHandleSupport

java.lang.Object
de.espirit.firstspirit.io.FileHandleSupport

public final class FileHandleSupport extends Object
Support for file handle operations.
Since:
5.2.501
  • Method Details

    • serializeTo

      public static void serializeTo(@NotNull @NotNull Object value, @NotNull @NotNull FileHandle targetFileHandle, @NotNull @NotNull ClassLoader classLoader) throws IOException
      Serializes the given value using a special serialization algorithm and stores it to the provided file handle.

      The class of given value and all referenced fields (recursivly) must provide a no arg constructor to be valid for serialization.

      To ensure proper serialization/deserialization, a class loader must be provided that enables to resolve public as well as custom types passed as value, e.g., getClass().getClassLoader() from within a module's scope.

      Parameters:
      value - The value to be serialized.
      targetFileHandle - The file handle to store to.
      classLoader - The responsible class loader.
      Throws:
      IOException - If storing the value went wrong.
      IllegalArgumentException - If given value is not serializable due to the contract of this method
      Since:
      5.2.504
    • deserializeFrom

      @Nullable public static @Nullable Object deserializeFrom(@NotNull @NotNull FileHandle handle, @NotNull @NotNull ClassLoader classLoader) throws IOException
      Deserializes a value from the given file handle according to the special serialization algorithm used by this supporting type.

      To ensure proper serialization/deserialization, a class loader must be provided that enables to resolve public as well as custom types passed as value, e.g., getClass().getClassLoader() from within a module's scope.

      Parameters:
      handle - The file handle to load from.
      classLoader - The responsible class loader.
      Returns:
      The deserialized value.
      Throws:
      IOException - If reading the value went wrong.
      Since:
      5.2.501