Annotation Type Persist


@Retention(RUNTIME) @Target(FIELD) public @interface Persist
A marker annotation for PersistenceLoader to persist a field by saving and loading it into DataKeys.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The specialised collection type to use when a super class is specified.
    The specific key type to use when deserialising Map keys from storage.
    If using global/static persistence, must be non-empty.
    boolean
    Whether to use PersistenceLoader to load/save the value of this class.
    boolean
    Whether a value must be present at load time.
    The DataKey path to use when saving/loading.
    The specific value type to use when deserialising values from storage.
  • Element Details

    • collectionType

      Class<?> collectionType
      The specialised collection type to use when a super class is specified. Eg. WeakHashMap.class when the field type is Map.
      Default:
      java.util.Collection.class
    • keyType

      Class<?> keyType
      The specific key type to use when deserialising Map keys from storage. Only supports primitive values and UUIDs currently.
      Default:
      java.lang.String.class
    • namespace

      String namespace
      If using global/static persistence, must be non-empty.
      Default:
      ""
    • reify

      boolean reify
      Whether to use PersistenceLoader to load/save the value of this class.
      Default:
      false
    • required

      boolean required
      Whether a value must be present at load time. If a value for the field could not be loaded, PersistenceLoader.load(Object, DataKey) will return null.
      Default:
      false
    • value

      String value
      The DataKey path to use when saving/loading. If not present, the field name will be used instead.
      • @Persist -> root key + field name
      • @Persist("") -> root key + "" (i.e. just the root key)
      • @Persist("sub") root key + "sub"
      • @Persist("$key") loads the root key, does not save
      Default:
      "UNINITIALISED"
    • valueType

      Class<?> valueType
      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.
      Default:
      java.lang.Object.class