Package com.helger.commons.text.resolve
Class AbstractEnumTextResolverWithOverrideAndFallback
- java.lang.Object
-
- com.helger.commons.text.resolve.AbstractEnumTextResolverWithOverrideAndFallback
-
- All Implemented Interfaces:
IEnumTextResolver
- Direct Known Subclasses:
EnumTextResolverWithPropertiesOverrideAndFallback
@ThreadSafe public abstract class AbstractEnumTextResolverWithOverrideAndFallback extends Object implements IEnumTextResolver
Resolves texts either from an override, a text provider or otherwise uses a fallback, based on the given enum constant.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CHECK_FOR_FALLBACKstatic booleanDEFAULT_CHECK_FOR_OVERRIDE
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEnumTextResolverWithOverrideAndFallback()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetText(Enum<?> aEnum, IHasText aTP, Locale aContentLocale)Get the text of an enumeration item.protected abstract StringinternalGetFallbackString(String sID, Locale aContentLocale)This method must return the fallback string for the passed parameters.protected abstract StringinternalGetOverrideString(String sID, Locale aContentLocale)This method must return the override string for the passed parameters.booleanisCheckForFallback()booleanisCheckForOverride()voidsetCheckForFallback(boolean bCheckForFallback)voidsetCheckForOverride(boolean bCheckForOverride)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.helger.commons.text.resolve.IEnumTextResolver
getTextWithArgs, getTextWithArgs
-
-
-
-
Field Detail
-
DEFAULT_CHECK_FOR_OVERRIDE
public static final boolean DEFAULT_CHECK_FOR_OVERRIDE
- See Also:
- Constant Field Values
-
DEFAULT_CHECK_FOR_FALLBACK
public static final boolean DEFAULT_CHECK_FOR_FALLBACK
- See Also:
- Constant Field Values
-
-
Method Detail
-
isCheckForOverride
public final boolean isCheckForOverride()
-
setCheckForOverride
public final void setCheckForOverride(boolean bCheckForOverride)
-
isCheckForFallback
public final boolean isCheckForFallback()
-
setCheckForFallback
public final void setCheckForFallback(boolean bCheckForFallback)
-
internalGetOverrideString
@Nullable protected abstract String internalGetOverrideString(@Nonnull String sID, @Nonnull Locale aContentLocale)
This method must return the override string for the passed parameters. This method is only called ifisCheckForOverride()istrue.- Parameters:
sID- Unique string IDaContentLocale- locale to use.- Returns:
- The string in the passed locale. May be
null.
-
internalGetFallbackString
@Nullable protected abstract String internalGetFallbackString(@Nonnull String sID, @Nonnull Locale aContentLocale)
This method must return the fallback string for the passed parameters. This method is only called ifisCheckForFallback()istrue.- Parameters:
sID- Unique string IDaContentLocale- locale to use.- Returns:
- The string in the passed locale. May be
null.
-
getText
@Nullable public final String getText(@Nonnull Enum<?> aEnum, @Nonnull IHasText aTP, @Nonnull Locale aContentLocale)
Description copied from interface:IEnumTextResolverGet the text of an enumeration item.- Specified by:
getTextin interfaceIEnumTextResolver- Parameters:
aEnum- The enumeration item to get the unique ID of. May not benull.aTP- The text provider containing the text. May not benull.aContentLocale- The locale to be used. May not benull.- Returns:
nullif no text could be resolved.
-
-