Package ch.njol.yggdrasil
Interface YggdrasilSerializable.YggdrasilExtendedSerializable
- All Superinterfaces:
YggdrasilSerializable
- All Known Subinterfaces:
Color
- All Known Implementing Classes:
AxolotlData
,BeeData
,BoatData
,CatData
,ColorRGB
,CreeperData
,DroppedItemData
,EndermanData
,EntityData
,FallingBlockData
,FishData
,FoxData
,GoatData
,GriefPreventionHook.GriefPreventionRegion
,GuardianData
,HorseData
,ItemData
,ItemType
,LlamaData
,MinecartData
,MooshroomData
,OcelotData
,PandaData
,ParrotData
,PigData
,PlayerData
,PreciousStonesHook.PreciousStonesRegion
,RabbitData
,Region
,ResidenceHook.ResidenceRegion
,SheepData
,SimpleEntityData
,SkeletonData
,SkriptColor
,ThrownPotionData
,TropicalFishData
,VillagerData
,WolfData
,WorldGuardHook.WorldGuardRegion
,XpOrbData
,ZombieVillagerData
- 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(@NonNull Fields fields)
Deserialises 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 serialisable
-
deserialize
Deserialises 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 Yggrdasil's default serialisation.NotSerializableException
-