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 arez components that triggers the generation of persistence code. 010 */ 011@Documented 012@Target( ElementType.TYPE ) 013public @interface PersistType 014{ 015 /** 016 * Return the name used to persist the type. 017 * If not specified, then the simple name of the class will be used. The name must comply with the 018 * requirements for a java identifier. 019 * 020 * <p>It should be noted that production mode persistent properties that are not persisted across 021 * reloads will use synthetic keys as an optimization strategy.</p> 022 * 023 * @return the name used to persist the property. 024 */ 025 @Nonnull 026 String name() default "<default>"; 027 028 /** 029 * The key identifying the default store where the observable data is stored. 030 * Individual properties annotated with the {@link Persist} annotation can still override the store used. 031 * The name of the defaultStore must comply with the requirements for a java identifier. 032 * 033 * @return the key identifying the default store where the observable data is stored. 034 */ 035 @Nonnull 036 String defaultStore() default StoreTypes.APPLICATION; 037 038 /** 039 * Setting controlling whether the sidecar attempts to force a persist of state when the sidecar is disposed. 040 * This is usually performed as part of the normal arez reaction cycle but can be skipped unless the sidecar 041 * is explicitly disposed within another arez transaction while a change has been made to persistent properties 042 * that have yet to be committed to the storage service. This is not normally a problem so it is disabled by 043 * default to reduce generated code size. 044 * 045 * @return true to force a persist when the sidecar is disposed, false otherwise. 046 */ 047 boolean persistOnDispose() default false; 048}