Class Gestalt
Gestalt manages the lifecycle of Feature-annotated classes, including
registration, initialization, enabling, disabling, and shutdown. Subclasses are
expected to provide platform-specific initialization and supply themselves via
GestaltSupplier.
The active instance can be retrieved globally via get().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDisables all registered features, respecting theirFeaturePriorityorder.voiddisableAllFeatures(@NotNull String group) Disables all registered features belonging to the specified group, respecting theirFeaturePriorityorder.voiddisableFeature(@NotNull Class<?> clazz) Disables a single registered feature class.voidEnables all registered features, respecting theirFeaturePriorityorder.voidenableAllFeatures(@NotNull String group) Enables all registered features belonging to the specified group, respecting theirFeaturePriorityorder.voidenableFeature(@NotNull Class<?> clazz) Enables a single registered feature class.static Gestaltget()Returns the globally activeGestaltinstance.getByGroup(@NotNull String group) Returns all registered feature classes belonging to the given group (case-insensitive).getByGroupAndIdentifier(@NotNull String group, @NotNull String identifier) Returns all registered feature classes matching both the given group and identifier (case-insensitive), sorted byFeaturePriority.getByIdentifier(@NotNull String identifier) Returns all registered feature classes with the given identifier (case-insensitive).getByPriority(@NotNull FeaturePriority priority) Returns all registered feature classes with the givenFeaturePriority.Returns theFeatureConditionProcessorresponsible for evaluating whether a feature's conditions are satisfied before enabling it.Returns theFeatureConstructorParamsRegistryused to store custom constructor parameters for feature instantiation.Returns all currently disabled (but registered) feature classes.Returns all currently enabled feature classes.Returns theFeatureListenerProcessorresponsible for processing and invoking methods annotated withFeatureListener.Returns theFeatureListenerRegistryused to register and dispatch feature lifecycle events to listener objects.Returns the server version string used for version-based feature conditions.Returns all registered feature classes sorted by theirFeaturePriority, fromFeaturePriority.HIGHESTtoFeaturePriority.LOWEST.booleanReturns whether the given feature class is currently enabled.voidRegisters one or more feature classes with Gestalt.voidregister(@NotNull GestaltFeature feature) Registers a feature described by aGestaltFeaturewrapper.voidunregister(@NotNull Class<?>... classes) Unregisters one or more feature classes from Gestalt.voidUnregisters all currently registered feature classes.
-
Constructor Details
-
Gestalt
Constructs a new Gestalt instance with the given server version and auto-update flag.- Parameters:
serverVersion- the server version string, used for version-based conditionsautoUpdate- whether the loader should auto-update features
-
-
Method Details
-
getServerVersion
Returns the server version string used for version-based feature conditions.- Returns:
- the server version
-
getConditionProcessor
Returns theFeatureConditionProcessorresponsible for evaluating whether a feature's conditions are satisfied before enabling it.- Returns:
- the condition processor
-
getListenerProcessor
Returns theFeatureListenerProcessorresponsible for processing and invoking methods annotated withFeatureListener.- Returns:
- the listener processor
-
getConstructorParamsRegistry
Returns theFeatureConstructorParamsRegistryused to store custom constructor parameters for feature instantiation.- Returns:
- the constructor parameters registry
-
getListenerRegistry
Returns theFeatureListenerRegistryused to register and dispatch feature lifecycle events to listener objects.- Returns:
- the listener registry
-
get
Returns the globally activeGestaltinstance.- Returns:
- the active Gestalt instance
- See Also:
-
register
Registers one or more feature classes with Gestalt.Each class must be annotated with
Feature. Upon registration, methods annotated withFeatureInitializeare invoked and aFeatureEvent.INITIALIZEevent is dispatched to all registered listeners. Classes that are already registered are silently skipped.- Parameters:
classes- the feature classes to register
-
register
Registers a feature described by aGestaltFeaturewrapper.If the wrapper provides custom
FeatureConstructorParams, they are stored in the constructor params registry before the feature class is registered.- Parameters:
feature- the feature descriptor containing the class and optional constructor params
-
unregister
Unregisters one or more feature classes from Gestalt.Methods annotated with
FeatureShutdownare invoked on each class, the class is removed from the internal registry, its constructor params are cleared, and aFeatureEvent.SHUTDOWNevent is dispatched to all listeners. Classes that are not registered are silently skipped.- Parameters:
classes- the feature classes to unregister
-
unregisterAllFeatures
public void unregisterAllFeatures()Unregisters all currently registered feature classes.Each feature's
FeatureShutdownmethods are invoked and listeners are notified withFeatureEvent.SHUTDOWN. -
enableFeature
Enables a single registered feature class.The feature is only enabled if it is currently disabled and all of its
conditionsare satisfied. Upon enabling, methods annotated withFeatureEnableare invoked and aFeatureEvent.ENABLEevent is dispatched to listeners.- Parameters:
clazz- the feature class to enable
-
disableFeature
Disables a single registered feature class.The feature is only disabled if it is currently enabled. Methods annotated with
FeatureDisableare invoked and aFeatureEvent.DISABLEevent is dispatched to listeners.- Parameters:
clazz- the feature class to disable
-
enableAllFeatures
public void enableAllFeatures()Enables all registered features, respecting theirFeaturePriorityorder. -
enableAllFeatures
Enables all registered features belonging to the specified group, respecting theirFeaturePriorityorder.- Parameters:
group- the feature group name to enable
-
disableAllFeatures
public void disableAllFeatures()Disables all registered features, respecting theirFeaturePriorityorder. -
disableAllFeatures
Disables all registered features belonging to the specified group, respecting theirFeaturePriorityorder.- Parameters:
group- the feature group name to disable
-
getByGroup
Returns all registered feature classes belonging to the given group (case-insensitive).- Parameters:
group- the group name to filter by- Returns:
- a list of matching feature classes
-
getByIdentifier
Returns all registered feature classes with the given identifier (case-insensitive).- Parameters:
identifier- the identifier to filter by- Returns:
- a list of matching feature classes
-
getByPriority
Returns all registered feature classes with the givenFeaturePriority.- Parameters:
priority- the priority to filter by- Returns:
- a list of matching feature classes
-
getByGroupAndIdentifier
public List<Class<?>> getByGroupAndIdentifier(@NotNull @NotNull String group, @NotNull @NotNull String identifier) Returns all registered feature classes matching both the given group and identifier (case-insensitive), sorted byFeaturePriority.- Parameters:
group- the group name to filter byidentifier- the identifier to filter by- Returns:
- a sorted list of matching feature classes
-
getSortedByPriority
Returns all registered feature classes sorted by theirFeaturePriority, fromFeaturePriority.HIGHESTtoFeaturePriority.LOWEST.- Returns:
- a priority-ordered list of all registered feature classes
-
getEnabledClasses
Returns all currently enabled feature classes.- Returns:
- a list of enabled feature classes
-
getDisabledClasses
Returns all currently disabled (but registered) feature classes.- Returns:
- a list of disabled feature classes
-
isEnabled
Returns whether the given feature class is currently enabled.- Parameters:
clazz- the feature class to check- Returns:
trueif the feature is enabled,falseotherwise
-