public interface Persistable extends Savable
PersistenceService.
The save() and restore() methods save/restore the component state to/from a JavaBean.
Exactly what is being saved and restored is up to a specific component - in general, one should not
expect that saving and then restoring a component will result in an identical object. Descriptors
returned by save() and taken by restore() should be independent of the internal state
of this Persistable.
The getDescriptor() method provides access to the descriptor maintained by this component.
Implementations are expected to ensure that any properties set on the descriptor returned by this
method are reflected by descriptors subsequently returned by save(), unless modified
between the two calls. Descriptors should extend Persistable.Descriptor - see that class
documentation for additional requirements.| Modifier and Type | Interface and Description |
|---|---|
static class |
Persistable.Descriptor
JavaBean that describes a state of a
Persistable component. |
| Modifier and Type | Method and Description |
|---|---|
default Persistable |
edit(String title,
Component parent)
Takes user input and returns a modified
Persistable instance. |
default String |
getCategory()
Returns the category this
Persistable belongs to. |
Persistable.Descriptor |
getDescriptor()
Returns a reference to the descriptor maintained by this component.
|
static String |
getPath(Persistable instance)
Returns a path for the specified
Persistable, its own if present, its Creator's otherwise. |
default void |
restore(Persistable.Descriptor descriptor)
Restores this component to the state specified by the provided JavaBean.
|
default void |
restore(Serializable descriptor)
Overrides
Savable.restore(Serializable) to forward the call to restore(Descriptor)
if the provided argument value is of type Persistable.Descriptor, and do nothing otherwise. |
default Persistable.Descriptor |
save()
Returns JavaBean describing the current state of this component.
|
default void restore(Serializable descriptor)
Savable.restore(Serializable) to forward the call to restore(Descriptor)
if the provided argument value is of type Persistable.Descriptor, and do nothing otherwise.default void restore(Persistable.Descriptor descriptor)
descriptor - JavaBean encapsulating the state.default Persistable.Descriptor save()
getDescriptor().Persistable.Descriptor getDescriptor()
null, and
that any properties set on the descriptor returned by this method are reflected by
descriptors subsequently returned by save(), unless modified between the two calls.default String getCategory()
Persistable belongs to.
The default implementation extracts the category from the descriptor.Persistable.default Persistable edit(String title, Component parent)
Persistable instance.
This method should be called on EDT.
The default implementation returns null.title - User-interaction dialog title, or null if the default title should be used.parent - Graphical component to be use as a parent for user-interaction dialog(s).this).
May return null to indicate that the Persistable should
be re-instantiated, letting the user select among available Creator
factories for the given category.CancellationException - If editing is canceled by the user.RuntimeException - If editing fails for any reason.static String getPath(Persistable instance)
Persistable, its own if present, its Creator's otherwise.instance - Persistable object.Copyright © 2023 LSST. All rights reserved.