Class RuntimeConversions
java.lang.Object
xyz.janboerman.scalaloader.configurationserializable.runtime.RuntimeConversions
This class servers as a fallback for the configuration serialization framework.
Generated serialize and deserializion methods may emit calls to serialize(Object, ParameterType, ClassLoader)
and deserialize(Object, ParameterType, ClassLoader)
if at classload-time it could not be established how an object should be (de)serialized.
To adjust the runtime serialization and deserialization behaviour, you can register a Codec
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clearCodecs
(IScalaPluginClassLoader scalaPlugin) Deprecated.internal use only.static <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader>
Objectdeserialize
(Object serialized, ParameterType type, ScalaPluginClassLoader pluginClassLoader) This method will be called by configuration serializable types for which ScalaLoader does not know how to handle them out of the box.static <T> boolean
registerCodec
(IScalaPluginClassLoader pluginClassLoader, Class<T> clazz, Codec<T, ?> codec) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.static boolean
registerCodec
(IScalaPluginClassLoader pluginClassLoader, Predicate<? super ParameterType> whenToUse, Function<? super ParameterType, ? extends Codec<?, ?>> codecFactory) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.static boolean
registerCodec
(IScalaPluginClassLoader pluginClassLoader, ParameterType type, Codec<?, ?> codec) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.static <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader>
Objectserialize
(Object live, ParameterType type, ScalaPluginClassLoader pluginClassLoader) This method will be called by configuration serializable types for which ScalaLoader does not know how to handle them out of the box.
-
Method Details
-
registerCodec
public static boolean registerCodec(IScalaPluginClassLoader pluginClassLoader, ParameterType type, Codec<?, ?> codec) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.- Parameters:
pluginClassLoader
- the classloader of your ScalaPlugintype
- the live type of the objects the codec should work withcodec
- the serializer and deserializer- Returns:
- true if the codec was registered, otherwise false
-
registerCodec
public static boolean registerCodec(IScalaPluginClassLoader pluginClassLoader, Predicate<? super ParameterType> whenToUse, Function<? super ParameterType, ? extends Codec<?, ?>> codecFactory) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.- Parameters:
pluginClassLoader
- the classloader of your ScalaPluginwhenToUse
- a predicate that will be tested once an object is serialized or deserializedcodecFactory
- a generator for a codec that is called once the predicate test succeeds.- Returns:
- true if the codec factory was registered, otherwise false
-
registerCodec
public static <T> boolean registerCodec(IScalaPluginClassLoader pluginClassLoader, Class<T> clazz, Codec<T, ?> codec) Register a codec that will be used byserialize(Object, ParameterType, ClassLoader)
anddeserialize(Object, ParameterType, ClassLoader)
.- Type Parameters:
T
- the type of the objects in their live form.- Parameters:
pluginClassLoader
- the classloader of your ScalaPluginclazz
- the live type of objects your codec should work withcodec
- the codec- Returns:
- true if the codec was registered, otherwise false
-
clearCodecs
Deprecated.internal use only. -
serialize
public static <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader> Object serialize(Object live, ParameterType type, ScalaPluginClassLoader pluginClassLoader) This method will be called by configuration serializable types for which ScalaLoader does not know how to handle them out of the box. You can register aCodec
usingregisterCodec(IScalaPluginClassLoader, ParameterType, Codec)
or its overloads so you can specify the behaviour at runtime.- Parameters:
live
- the object that is going to be serializedtype
- the type of the live objectpluginClassLoader
- the classloader of your plugin- Returns:
- the object in its serialized form
-
deserialize
public static <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader> Object deserialize(Object serialized, ParameterType type, ScalaPluginClassLoader pluginClassLoader) This method will be called by configuration serializable types for which ScalaLoader does not know how to handle them out of the box. You can register aCodec
usingregisterCodec(IScalaPluginClassLoader, ParameterType, Codec)
or its overloads so you can specify the behaviour at runtime.- Parameters:
serialized
- the object that is going to be deserializedtype
- the type of the live objectpluginClassLoader
- the classloader of your plugin- Returns:
- object in its live form
-