001package arez.persist;
002
003import java.lang.annotation.Documented;
004import java.lang.annotation.ElementType;
005import java.lang.annotation.Target;
006import javax.annotation.Nonnull;
007
008/**
009 * Annotation applied to observable properties that direct Arez to persist the property.
010 */
011@Documented
012@Target( ElementType.METHOD )
013public @interface Persist
014{
015  /**
016   * Return the name used to persist the property.
017   * If unspecified and the method is named according to javabeans getter conventions then the java bean property name
018   * will be used, otherwise the name of the method will be used. It should be notes that during the code generation
019   * the name will also be used to look up the setter used to restore the property. So if the property is named
020   * {@code expanded} then the library will expect a setter method named {@code setExpanded}.
021   *
022   * <p>It should be noted that production mode persistent properties that are not persisted across
023   * reloads will use synthetic keys as an optimization strategy.</p>
024   *
025   * @return the name used to persist the property.
026   */
027  @Nonnull
028  String name() default "<default>";
029
030  /**
031   * The key identifying the store where the observable data is stored.
032   * The name of the store must comply with the requirements for a java identifier.
033   *
034   * @return the key identifying the store where the observable data is stored.
035   */
036  @Nonnull
037  String store() default "<default>";
038
039  /**
040   * Return the name of the setter.
041   * If unspecified the tool assumes that the setter method is named according to javabeans setter based on the derived
042   * {@link #name()} of the property. So if the property is named {@code expanded} then the library will
043   * derive a setter method named {@code setExpanded}.
044   *
045   * @return the name of the setter used to update value when restoring from a persisted store.
046   */
047  @Nonnull
048  String setterName() default "<default>";
049}