Class MessageSourceMessageComparator<T>

java.lang.Object
net.solarnetwork.node.settings.support.MessageSourceMessageComparator<T>
Type Parameters:
T - the comparison type
All Implemented Interfaces:
Comparator<T>
Direct Known Subclasses:
SettingSpecifierProviderFactoryMessageComparator, SettingSpecifierProviderMessageComparator

public abstract class MessageSourceMessageComparator<T> extends Object implements Comparator<T>
Abstract Comparator for comparing two resolved messages.
Since:
1.74
Version:
1.0
Author:
matt
  • Field Details

    • DEFAULT_MESSAGE_KEY

      public static final String DEFAULT_MESSAGE_KEY
      The default messageKey property value.
      See Also:
  • Constructor Details

    • MessageSourceMessageComparator

      public MessageSourceMessageComparator(Locale locale)
      Constructor.

      This defaults the messageKey to DEFAULT_MESSAGE_KEY.

      Parameters:
      locale - the desired locale of the messages to compare
    • MessageSourceMessageComparator

      public MessageSourceMessageComparator(Locale locale, String messageKey)
      Constructor.
      Parameters:
      locale - the desired locale of the messages to compare
      messageKey - the message key to compare
  • Method Details

    • compareMessageKeyValues

      public int compareMessageKeyValues(org.springframework.context.MessageSource leftMessageSource, String leftDefault, org.springframework.context.MessageSource rightMessageSource, String rightDefault)
      Compare two resolved message keys in a case-insensitive manner.
      Parameters:
      leftMessageSource - the first message source, or null
      leftDefault - the first default message, if leftMessageSource is not available or does not resolve a value for getMessageKey()
      rightMessageSource - the second message source, or null
      rightDefault - the second default message, if rightMessageSource is not available or does not resolve a value for getMessageKey()
      Returns:
      a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
    • getLocale

      public Locale getLocale()
      Get the locale.
      Returns:
      the locale
    • getMessageKey

      public String getMessageKey()
      Get the message key.
      Returns:
      the messageKey