Package ch.njol.yggdrasil
Interface YggdrasilSerializable.YggdrasilExtendedSerializable
- All Superinterfaces:
YggdrasilSerializable
- All Known Subinterfaces:
Color
- All Known Implementing Classes:
ColorRGB
,SkriptColor
- Enclosing interface:
YggdrasilSerializable
public static interface YggdrasilSerializable.YggdrasilExtendedSerializable
extends YggdrasilSerializable
A class that has transient fields or more generally wants to exactly
define which fields to write to/read from stream should implement this interface.
It provides two methods similar to Java's writeObject and readObject methods.
If a class implements this interface implementing YggdrasilSerializable.YggdrasilRobustSerializable
as well is pointless since its methods won't get called.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialize
(@NotNull Fields fields) Deserializes this object.Serialises this object.
-
Method Details
-
serialize
Serialises this object. Only fields contained in the returned Fields object will be written to stream.You can use return new
Fields
(this); to emulate the default behaviour.- Returns:
- A Fields object containing all fields that should be written to stream
- Throws:
NotSerializableException
- If this object or one of its fields is not serializable
-
deserialize
void deserialize(@NotNull @NotNull Fields fields) throws StreamCorruptedException, NotSerializableException Deserializes this object. No fields have been set when this method is called, use fields.setFields
(this, yggdrasil) to set all compatible non-transient and non-static fields (and call incompatible/missing field handlers if applicable – this implies that errors will be thrown if the fields object is invalid).You can use fields.
setFields
(this); to emulate the default behaviour.- Parameters:
fields
- A Fields object containing all fields read from stream- Throws:
StreamCorruptedException
- If the Fields object is invalid, i.e. was not written byserialize()
or Yggdrasil's default serialisation.NotSerializableException
-