Package net.citizensnpcs.api.persistence
Class PersistenceLoader
java.lang.Object
net.citizensnpcs.api.persistence.PersistenceLoader
Performs reflective persistence of objects into 
DataKeys. Persist annotations are used to mark fields
 for annotation.- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> PersisterRegistry<T> createRegistry(Class<?> base) static <T> TCreates an instance of the given class using the default constructor and loads it usingload(Object, DataKey).static <T> Tstatic voidregisterPersistDelegate(Class<?> clazz, Class<? extends Persister<?>> delegateClass) Registers aPersisterredirect.static void
- 
Constructor Details- 
PersistenceLoaderpublic PersistenceLoader()
 
- 
- 
Method Details- 
createRegistry
- 
loadCreates an instance of the given class using the default constructor and loads it usingload(Object, DataKey). Will return null if an exception occurs.- Parameters:
- clazz- The class to create an instance from
- root- The root key to load from
- Returns:
- The loaded instance
- See Also:
 
- 
loadAnalyses the class forFields with thePersistannotation and loads data into them using the givenDataKey. If aDelegatePersistenceannotation is provided the referencedPersisterwill be used to create the instance. This annotation can be omitted if the Persister has been registered usingregisterPersistDelegate(Class, Class)- Parameters:
- instance- The instance to load data into
- root- The key to load data from
- Returns:
- The instance, with persisted fields loaded
 
- 
registerPersistDelegatepublic static void registerPersistDelegate(Class<?> clazz, Class<? extends Persister<?>> delegateClass) Registers aPersisterredirect. Fields or constructors with thePersistannotation with a type that has been registered using this method will use the suppliedPersisterfor (de)serialisation. TheDelegatePersistenceannotation will be preferred if present.- Parameters:
- clazz- The class to redirect
- delegateClass- The Persister class to use when loading and saving
 
- 
save- Parameters:
- instance- The instance to save
- root- The key to save into
 
 
-