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
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringGet 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.final booleanfinal booleanfinal voidsetCheckForFallback(boolean bCheckForFallback) final voidsetCheckForOverride(boolean bCheckForOverride) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.text.resolve.IEnumTextResolver
getTextWithArgs, getTextWithArgs
-
Field Details
-
DEFAULT_CHECK_FOR_OVERRIDE
public static final boolean DEFAULT_CHECK_FOR_OVERRIDE- See Also:
-
DEFAULT_CHECK_FOR_FALLBACK
public static final boolean DEFAULT_CHECK_FOR_FALLBACK- See Also:
-
-
Constructor Details
-
AbstractEnumTextResolverWithOverrideAndFallback
protected AbstractEnumTextResolverWithOverrideAndFallback()
-
-
Method Details
-
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.
-