public final class FileHandleSupport extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
deserializeFrom(FileHandle handle,
ClassLoader classLoader)
Deserializes a value from the given file handle according to the special serialization algorithm used by this
supporting type.
|
static void |
serializeTo(Object value,
FileHandle targetFileHandle,
ClassLoader classLoader)
Serializes the given value using a special serialization algorithm and stores it to the provided file handle.
|
public static void serializeTo(@NotNull Object value, @NotNull FileHandle targetFileHandle, @NotNull ClassLoader classLoader) throws IOException
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.
value
- The value to be serialized.targetFileHandle
- The file handle to store to.classLoader
- The responsible class loader.IOException
- If storing the value went wrong.IllegalArgumentException
- If given value is not serializable due to the contract of this method@Nullable public static Object deserializeFrom(@NotNull FileHandle handle, @NotNull ClassLoader classLoader) throws IOException
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.
handle
- The file handle to load from.classLoader
- The responsible class loader.IOException
- If reading the value went wrong.Copyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210