Skip to content

Commit

Permalink
Update some javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 22, 2022
1 parent 3d19066 commit 7cbaaa0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/citizensnpcs/api/persistence/Persist.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.citizensnpcs.api.util.DataKey;

/**
* Tells the {@link PersistenceLoader} to persist this field by saving and loading it into {@link DataKey}s.
* A marker annotation for {@link PersistenceLoader} to persist a field by saving and loading it into {@link DataKey}s.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
Expand All @@ -21,8 +21,8 @@
Class<?> collectionType() default Collection.class;

/**
* The specific value type to use when deserialising values from storage. Most useful when using specific number
* types e.g. Long, Byte, Short but storing as Integer.
* The specific key type to use when deserialising Map keys from storage. Only supports primitive values and UUIDs
* currently.
*/
Class<?> keyType() default String.class;

Expand All @@ -43,11 +43,11 @@
boolean required() default false;

/**
* The save key to use when saving. If not present, the field name will be used instead.
* The DataKey path to use when saving. If not present, the field name will be used instead.
*
* <ul>
* <li><code>@Persist</code> -> root key + field name</li>
* <li><code>@Persist("")</code> -> root key + "" (or simply root key)</li>
* <li><code>@Persist("")</code> -> root key + "" (i.e. just the root key)</li>
* <li><code>@Persist("sub")</code> root key + "sub"</li>
* </ul>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import net.citizensnpcs.api.util.DataKey;

/**
* A persistable instance that can be saved and loaded using {@link DataKey}
*
* @see PersistenceLoader#registerPersistDelegate(Class, Class)
* An Object that can be serialised using {@link DataKey}s. {@link PersistenceLoader} will call these methods when
* serialising objects.
*/
public interface Persistable {
public void load(DataKey root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import net.citizensnpcs.api.util.DataKey;

/**
* The main registry for managing reflective, recursive {@link net.citizensnpcs.api.npc.NPC} persistence.
* Performs reflective persistence of objects into {@link DataKey}s. {@link Persist} annotations are used to mark fields
* for annotation.
*
* @see Persist
* @see #registerPersistDelegate(Class, Class)
*/
public class PersistenceLoader {
private static class GenericPersister implements Persister<Object> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@

import net.citizensnpcs.api.util.DataKey;

/**
* A stringly-typed registry that loads and saves its types using {@link PersistenceLoader} and {@link DataKey}s.
**/
public class PersisterRegistry<T> implements Persister<T> {
private final Map<String, WeakReference<Class<? extends T>>> registry = Maps.newHashMap();

PersisterRegistry() {
}

@Override
public T create(DataKey root) {
String type = root.getString("type");
Expand Down

0 comments on commit 7cbaaa0

Please sign in to comment.