public abstract class AbstractPreferencesManager extends Object implements PreferencesManager
Modifier and Type | Field and Description |
---|---|
protected GriffonApplication |
application |
protected InstanceStore |
instanceStore |
protected KeyResolutionStrategy |
keyResolutionStrategy |
Constructor and Description |
---|
AbstractPreferencesManager() |
Modifier and Type | Method and Description |
---|---|
protected Object |
convertValue(Class<?> type,
Object value,
String format,
Class<? extends PropertyEditor> editor) |
protected void |
doPreferencesInjection(Object instance,
Map<String,PreferenceDescriptor> descriptors) |
protected void |
doSavePreferences(Object instance,
Map<String,PreferenceDescriptor> descriptors) |
protected Object |
evalPreferenceWithArguments(Object value,
Object[] args) |
protected String |
formatPreferenceValue(String message,
Object[] args) |
protected void |
harvestDescriptors(Class instanceClass,
Class currentClass,
Object instance,
Map<String,PreferenceDescriptor> descriptors) |
void |
injectPreferences(Object instance)
Loads a matching
PreferencesNode into the target instance. |
protected boolean |
isNoopPropertyEditor(Class<? extends PropertyEditor> editor) |
protected String[] |
parsePath(String path) |
protected Class<?> |
resolveClass(Class<?> instanceClass,
Class<?> declaringClass) |
protected Object |
resolvePreference(String path,
String[] args,
String defaultValue) |
protected PropertyEditor |
resolvePropertyEditor(Class<?> type,
String format,
Class<? extends PropertyEditor> editor) |
void |
save(Object instance)
Merges all fields/properties annotated with
@Preference to their
corresponding PreferencesNode within the contained Preferences . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPreferences
@Inject protected GriffonApplication application
protected final InstanceStore instanceStore
protected KeyResolutionStrategy keyResolutionStrategy
public void save(@Nonnull Object instance)
PreferencesManager
Merges all fields/properties annotated with @Preference
to their
corresponding PreferencesNode
within the contained Preferences
.
Values will be transformed their literal representation if a format
is present in their @Preference
annotation. Null values will cause
the removal of the key in the PreferencesNode
.
save
in interface PreferencesManager
instance
- an object with fields/properties annotated with @Preference
.public void injectPreferences(@Nonnull Object instance)
PreferencesManager
PreferencesNode
into the target instance.injectPreferences
in interface PreferencesManager
instance
- an object with fields/properties annotated with @Preference
.protected void harvestDescriptors(@Nonnull Class instanceClass, @Nonnull Class currentClass, @Nonnull Object instance, @Nonnull Map<String,PreferenceDescriptor> descriptors)
@Nonnull protected Class<?> resolveClass(@Nonnull Class<?> instanceClass, @Nonnull Class<?> declaringClass)
protected void doPreferencesInjection(@Nonnull Object instance, @Nonnull Map<String,PreferenceDescriptor> descriptors)
protected void doSavePreferences(@Nonnull Object instance, @Nonnull Map<String,PreferenceDescriptor> descriptors)
@Nullable protected Object resolvePreference(@Nonnull String path, @Nonnull String[] args, @Nullable String defaultValue)
@Nullable protected Object evalPreferenceWithArguments(@Nullable Object value, @Nullable Object[] args)
@Nonnull protected String formatPreferenceValue(@Nonnull String message, @Nullable Object[] args)
@Nonnull protected Object convertValue(@Nonnull Class<?> type, @Nonnull Object value, @Nullable String format, @Nonnull Class<? extends PropertyEditor> editor)
@Nonnull protected PropertyEditor resolvePropertyEditor(@Nonnull Class<?> type, @Nullable String format, @Nonnull Class<? extends PropertyEditor> editor)
protected boolean isNoopPropertyEditor(@Nonnull Class<? extends PropertyEditor> editor)