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 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 if isCheckForOverride() is true .
      Parameters:
      sID - Unique string ID
      aContentLocale - 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 if isCheckForFallback() is true .
      Parameters:
      sID - Unique string ID
      aContentLocale - 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: IEnumTextResolver
      Get the text of an enumeration item.
      Specified by:
      getText in interface IEnumTextResolver
      Parameters:
      aEnum - The enumeration item to get the unique ID of. May not be null.
      aTP - The text provider containing the text. May not be null.
      aContentLocale - The locale to be used. May not be null.
      Returns:
      null if no text could be resolved.