Package io.micronaut.core.optim
Class StaticOptimizations
java.lang.Object
io.micronaut.core.optim.StaticOptimizations
This class is a generic container for pre-computed data
which can be injected at initialization time. Every class
which needs static optimizations should go through this
class to get its static state.
- Since:
- 3.2.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface for an optimization which will be injected via service loading. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Enables environment caching.Returns, if available, the optimization data of the requested type.static boolean
Returns true if the environment should be cached, that is to say if the environment variables and system properties are deemed immutable during the whole application run time.static <T> void
set
(T value) Injects an optimization.
-
Constructor Details
-
StaticOptimizations
public StaticOptimizations()
-
-
Method Details
-
cacheEnvironment
public static void cacheEnvironment()Enables environment caching. If enabled, both the environment variables and system properties will be deemed immutable. -
get
Returns, if available, the optimization data of the requested type. Those optimizations are singletons, which is why they are accessed by type.- Type Parameters:
T
- the optimization type- Parameters:
optimizationClass
- the type of the optimization class- Returns:
- the optimization if set, otherwise empty
-
set
Injects an optimization. Optimizations must be immutable final data classes: there's a one-to-one mapping between an optimization class and its associated data.- Type Parameters:
T
- the type of the optimization- Parameters:
value
- the optimization to store
-
isEnvironmentCached
public static boolean isEnvironmentCached()Returns true if the environment should be cached, that is to say if the environment variables and system properties are deemed immutable during the whole application run time.- Returns:
- true if the environment is cached
-