public class PersistenceLoader extends Object
NPC
persistence.Persist
,
registerPersistDelegate(Class, Class)
Constructor and Description |
---|
PersistenceLoader() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
load(Class<? extends T> clazz,
DataKey root)
Creates an instance of the given class using the default constructor and loads it using
load(Object, DataKey) . |
static <T> T |
load(T instance,
DataKey root)
|
static void |
registerPersistDelegate(Class<?> clazz,
Class<? extends Persister<?>> delegateClass)
Registers a
Persister redirect. |
static void |
save(Object instance,
DataKey root)
|
public static <T> T load(Class<? extends T> clazz, DataKey root)
load(Object, DataKey)
. Will return null if an exception occurs.clazz
- The class to create an instance fromroot
- The root key to load fromload(Object, DataKey)
public static <T> T load(T instance, DataKey root)
Field
s with the Persist
annotation and loads data into them using the
given DataKey
. If a DelegatePersistence
annotation is provided the referenced Persister
will be used to create the instance. This annotation can be omitted if the Persister has been registered using
registerPersistDelegate(Class, Class)
instance
- The instance to load data intoroot
- The key to load data frompublic static void registerPersistDelegate(Class<?> clazz, Class<? extends Persister<?>> delegateClass)
Persister
redirect. Fields with the Persist
annotation with a type that has been
registered using this method will use the Persister by default to load and save data. The
DelegatePersistence
annotation will be preferred if present.clazz
- The class to redirectdelegateClass
- The Persister class to use when loading and savingCopyright © 2021. All rights reserved.