Class ZoneRulesInitializer
- Direct Known Subclasses:
ZoneRulesInitializer.DoNothingZoneRulesInitializer,ZoneRulesInitializer.ServiceLoaderZoneRulesInitializer
The default behavior is to use ServiceLoader to find instances of ZoneRulesProvider.
Use the setInitializer(ZoneRulesInitializer) method to replace this behavior.
The initializer instance must perform the work of creating the ZoneRulesProvider within
the initializeProviders() method to ensure that the provider is not initialized too early.
The initializer must be set before class loading of any other ThreeTen-Backport class to have any effect!
This class has been added primarily for the benefit of Android.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classImplementation that does nothing.(package private) static classImplementation that uses the service loader. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ZoneRulesInitializerAn instance that does nothing.private static final AtomicBooleanprivate static final AtomicReference<ZoneRulesInitializer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidprotected abstract voidInitialize the providers.static voidsetInitializer(ZoneRulesInitializer initializer) Sets the initializer to use.
-
Field Details
-
DO_NOTHING
An instance that does nothing. CallsetInitializer(ZoneRulesInitializer)with this instance to block the service loader search. This will leave the system with no providers. -
INITIALIZED
-
INITIALIZER
-
-
Constructor Details
-
ZoneRulesInitializer
public ZoneRulesInitializer()
-
-
Method Details
-
setInitializer
Sets the initializer to use.This can only be invoked before the
ZoneRulesProviderclass is loaded. Invoking this method at a later point will throw an exception.- Parameters:
initializer- the initializer to use- Throws:
IllegalStateException- if initialization has already occurred or another initializer has been set
-
initialize
static void initialize() -
initializeProviders
protected abstract void initializeProviders()Initialize the providers.The implementation should perform whatever work is necessary to initialize the providers. This will result in one or more calls to
ZoneRulesProvider.registerProvider(ZoneRulesProvider).It is vital that the instance of
ZoneRulesProvideris not created until this method is invoked.It is guaranteed that this method will be invoked once and only once.
-