com.codepulsar.nils.api.NilsFactory Maven / Gradle / Ivy
Show all versions of nils-core Show documentation
package com.codepulsar.nils.api;
import java.util.Locale;
import com.codepulsar.nils.core.handler.ClassPrefixResolver;
import com.codepulsar.nils.core.impl.NilsFactoryImpl;
/** Factory for getting access to the provided NLS. A requested NLS object is cached. */
public interface NilsFactory {
/**
* Get the NLS object for the default Locale
.
*
* @return The NLS object for the default Locale
.
*/
NLS nls();
/**
* Get the NLS object for a language tag.
*
* @param lang The language tag.
* @return The NLS object for the language tag.
* @see Locale#forLanguageTag(String)
*/
NLS nls(String lang);
/**
* Get the NLS object for a specific Locale
.
*
* @param locale The Locale
.
* @return The NLS object for the Locale
.
*/
NLS nls(Locale locale);
/**
* Get the NLS object for the default Locale
and a specific context.
*
* Only the keys beneath the context will be examined.
*
* @param context The context key.
* @return The NLS object for the default Locale
.
*/
NLS nlsWithContext(String context);
/**
* Get the NLS object for a language tag and a specific context.
*
*
Only the keys beneath the context will be examined.
*
* @param lang The language tag.
* @param context The context key.
* @return The NLS object for the language tag.
* @see Locale#forLanguageTag(String)
*/
NLS nlsWithContext(String lang, String context);
/**
* Get the NLS object for a specific Locale
and a specific context.
*
*
Only the keys beneath the context will be examined.
*
* @param locale The Locale
.
* @param context The context key.
* @return The NLS object for the Locale
.
*/
NLS nlsWithContext(Locale locale, String context);
/**
* Get the NLS object for the default Locale
and a specific context based on a
* Class
.
*
*
Only the keys beneath the context will be examined.
*
*
The determination of the Class as key will be done with the configured {@link
* ClassPrefixResolver}.
*
* @param context The Class
for the context key.
* @return The NLS object for the default Locale
.
*/
NLS nlsWithContext(Class> context);
/**
* Get the NLS object for a language tag and a specific context based on a
* Class
.
*
*
Only the keys beneath the context will be examined.
*
*
The determination of the Class as key will be done with the configured {@link
* ClassPrefixResolver}.
*
*
Only the keys beneath the context will be examined.
*
* @param lang The language tag.
* @param context The Class
for the context key.
* @return The NLS object for the language tag.
* @see Locale#forLanguageTag(String)
*/
NLS nlsWithContext(String lang, Class> context);
/**
* Get the NLS object for a language tag and a specific context based on a
* Class
.
*
*
Only the keys beneath the context will be examined.
*
*
The determination of the Class as key will be done with the configured {@link
* ClassPrefixResolver}.
*
* @param locale The Locale
.
* @param context The Class
for the context key.
* @return The NLS object for the language tag.
* @see Locale#forLanguageTag(String)
*/
NLS nlsWithContext(Locale locale, Class> context);
/**
* Reset the {@link NilsFactory} and all its cached elements.
*
*
Note: The implementation is synchronized.
*/
void reset();
/**
* Initialize the factory using a {@link NilsConfig}.
*
* @param config A {@link NilsConfig} object.
* @return The create factory.
*/
static NilsFactory init(NilsConfig> config) {
return new NilsFactoryImpl(config);
}
}