public interface PropertyLoader
Properties
according to a
Locale
setting, which delegate method invocations to be fetched from
resource bundles
.
A property accessor interface is an interface to provide an API over static
properties and localized text and data. Users should not implement this class
themselves, instead they should define sub-interfaces, allowing
implementations to be automatically provided by PropertyLoader
.
User defined methods on a property accessor interface may return values of
any type, so long as a PropertyValueProvider
is given to the property
loader which supports that type. Special handling is performed for the
Localized
type, and for methods returning nested accessor classes.
A key is generated for each method based on the class and method name. The
key is generated according to the PropertyConfiguration
used to load
the Properties
instance.
Default and static methods will be invoked directly.
A Properties
instance is Observable
over changes to its
locale, with the instance itself being passed as the message to observers.
For an example of how to use this interface, users may wish to take a look at
the PropertyLoaderProperties
interface.
Modifier and Type | Field and Description |
---|---|
static PropertyLoader |
DEFAULT_PROPERTY_LOADER
As returned by
getDefaultPropertyLoader() . |
Modifier and Type | Method and Description |
---|---|
static <T> T |
getDefaultProperties(java.lang.Class<T> accessor)
Generate an implementing instance of the given accessor interface class,
according to the rules described by
Properties . |
static <T> T |
getDefaultProperties(PropertyAccessorConfiguration<T> accessorConfiguration)
Get a
property implementation from the
default loader . |
static PropertyLoader |
getDefaultPropertyLoader()
Get a simple
PropertyLoader implementation over the
system locale . |
java.util.Locale |
getLocale() |
PropertyLoaderProperties |
getProperties() |
default <T> T |
getProperties(java.lang.Class<T> accessor)
Generate an implementing instance of the given accessor interface class,
according to the rules described by
Properties . |
<T> T |
getProperties(PropertyAccessorConfiguration<T> accessorConfiguration)
Generate an implementing instance of the given accessor interface class,
according to the rules described by
Properties . |
static PropertyLoader |
getPropertyLoader(LocaleProvider provider)
Get a simple
PropertyLoader implementation over the given locale
provider. |
static PropertyLoader |
getPropertyLoader(LocaleProvider provider,
Log log)
Get a simple
PropertyLoader implementation over the given locale
provider. |
java.util.Set<java.lang.Class<? extends PropertyResourceStrategy<?>>> |
getResourceStrategies() |
<T extends PropertyResourceStrategy<T>> |
getResourceStrategy(java.lang.Class<T> strategy) |
java.util.Optional<PropertyValueProvider<?>> |
getValueProvider(java.lang.reflect.AnnotatedType type) |
java.util.List<PropertyValueProviderFactory> |
getValueProviders() |
ObservableValue<java.util.Locale> |
locale() |
<T extends PropertyResourceStrategy<T>> |
registerResourceStrategy(T strategy) |
boolean |
registerValueProvider(PropertyValueProviderFactory propertyProvider) |
<T extends PropertyResourceStrategy<T>> |
setDefaultResourceStrategy(T strategy) |
<T extends PropertyResourceStrategy<T>> |
unregisterResourceStrategy(T strategy) |
boolean |
unregisterValueProvider(PropertyValueProviderFactory propertyProvider) |
static final PropertyLoader DEFAULT_PROPERTY_LOADER
getDefaultPropertyLoader()
.java.util.Locale getLocale()
PropertyLoader
ObservableValue<java.util.Locale> locale()
boolean registerValueProvider(PropertyValueProviderFactory propertyProvider)
propertyProvider
- a provider for a type of propertyboolean unregisterValueProvider(PropertyValueProviderFactory propertyProvider)
propertyProvider
- a provider for a type of propertyjava.util.List<PropertyValueProviderFactory> getValueProviders()
java.util.Optional<PropertyValueProvider<?>> getValueProvider(java.lang.reflect.AnnotatedType type)
type
- the exact annotated type to providefactories
over the given type<T extends PropertyResourceStrategy<T>> boolean registerResourceStrategy(T strategy)
strategy
- the strategy to register<T extends PropertyResourceStrategy<T>> boolean unregisterResourceStrategy(T strategy)
strategy
- the strategy to unregisterjava.util.Set<java.lang.Class<? extends PropertyResourceStrategy<?>>> getResourceStrategies()
<T extends PropertyResourceStrategy<T>> T getResourceStrategy(java.lang.Class<T> strategy)
<T extends PropertyResourceStrategy<T>> void setDefaultResourceStrategy(T strategy)
<T> T getProperties(PropertyAccessorConfiguration<T> accessorConfiguration)
Properties
.T
- the type of the localization text accessor interfaceaccessorConfiguration
- configuration object for the sub-interface of Properties
we
wish to implement, and the default property configuration to applydefault <T> T getProperties(java.lang.Class<T> accessor)
Properties
.T
- the type of the localization text accessor interfaceaccessor
- the sub-interface of Properties
we wish to implementPropertyLoaderProperties getProperties()
static PropertyLoader getDefaultPropertyLoader()
PropertyLoader
implementation over the
system locale
.PropertyLoader
for the system localestatic <T> T getDefaultProperties(PropertyAccessorConfiguration<T> accessorConfiguration)
property implementation
from the
default loader
.T
- the type of the localization text accessor interfaceaccessorConfiguration
- configuration object for the sub-interface of Properties
we
wish to implement, and the default property configuration to applystatic <T> T getDefaultProperties(java.lang.Class<T> accessor)
Properties
.T
- the type of the localization text accessor interfaceaccessor
- the sub-interface of Properties
we wish to implementstatic PropertyLoader getPropertyLoader(LocaleProvider provider)
PropertyLoader
implementation over the given locale
provider.provider
- a provider to establish a locale settingPropertyLoader
for the given localestatic PropertyLoader getPropertyLoader(LocaleProvider provider, Log log)
PropertyLoader
implementation over the given locale
provider.provider
- a provider to establish a locale settinglog
- a log for localization informationPropertyLoader
for the given locale