Class Interest<K>

java.lang.Object
org.springframework.data.gemfire.client.Interest<K>
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
KeyInterest, RegexInterest

public class Interest<K> extends Object implements InitializingBean
The Interest class holds details for registering a client interest.
Since:
1.0.0
Author:
Costin Leau, John Blum
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • newInterest

      public static <K> Interest newInterest(K key)
      Factory method to construct a new instance of Interest initialized with the given key.
      Type Parameters:
      K - Class type of the key.
      Parameters:
      key - key of interest.
      Returns:
      a new instance of Interest initialized with the given key.
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface InitializingBean
    • resolveType

      protected Interest.Type resolveType(Interest.Type type)
      Attempts to resolve the Interest.Type based on the configured getKey().
      Parameters:
      type - provided Interest.Type used if non-null.
      Returns:
      the resolved Interest.Type.
      See Also:
    • isRegularExpression

      protected boolean isRegularExpression(Object key)
      Determines whether the given key is a Regular Expression (Regex). If the given key is "ALL_KEYS", a List or only contains letters, numbers and spaces, then the key is not considered a Regular Expression by GemFire, and can be handled with normal interest registration using Region.registerInterest(Object).
      Parameters:
      key - Object to evaluate.
      Returns:
      a boolean value indicating whether the given Object key is a Regular Expression.
      See Also:
    • isRegularExpression

      protected boolean isRegularExpression(String value)
      Determines whether the given key is a Regular Expression (Regex). If the given value contains at least 1 special character (e.g. *) and can be compiled using Pattern.compile(String), then the key is considered a Regular Expression and interest will be registered using Region.registerInterestRegex(String).
      Parameters:
      value - String to evaluate.
      Returns:
      a boolean value indicating whether the given String value is a Regular Expression.
      See Also:
    • containsNonAlphaNumericWhitespace

      protected boolean containsNonAlphaNumericWhitespace(String value)
      Determines whether the given String value contains at least 1 special character.
      Parameters:
      value - String to evaluate.
      Returns:
      a boolean value indicating whether the given String contains at least 1 special character, a non-alphanumeric, non-whitespace character.
      See Also:
    • isNotAlphaNumericWhitespace

      protected boolean isNotAlphaNumericWhitespace(char character)
      Determines whether the given character is a special character (non-alphanumeric, non-whitespace).
      Parameters:
      character - Character to evaluate.
      Returns:
      a boolean value indicating whether the given character is a special character.
      See Also:
    • isAlphaNumericWhitespace

      protected boolean isAlphaNumericWhitespace(char character)
      Determines whether the given character is an alphanumeric or whitespace character.
      Parameters:
      character - Character to evaluate.
      Returns:
      a boolean value indicating whether the given character is an alphanumeric or whitespace character.
      See Also:
    • isDurable

      public boolean isDurable()
      Determines whether the interest registration is durable and persists between cache client sessions.
      Returns:
      a boolean value indicating whether this interest registration is durable.
    • setDurable

      public void setDurable(boolean durable)
      Sets whether interest registration is durable and persists between cache client sessions.
      Parameters:
      durable - boolean value to indicate whether this interest registration is durable.
    • getKey

      public K getKey()
      Returns the key on which interest is registered.
      Returns:
      the key of interest.
    • setKey

      public void setKey(K key)
      Sets the key on which interest is registered.
      Parameters:
      key - the key of interest.
    • getPolicy

      public InterestResultPolicy getPolicy()
      Returns the InterestResultPolicy used when interest is registered and determines whether KEYS, KEYS_VALUES or nothing (NONE) is initially fetched on initial registration.
      Returns:
      the policy
    • setPolicy

      public void setPolicy(Object policy)
      Sets the initial InterestResultPolicy used when interest is first registered and determines whether KEYS, KEYS_VALUE or nothing (NONE) is initially fetched. The argument is set as an Object to be able to accept both InterestResultPolicy and Strings, used in XML configuration meta-data.
      Parameters:
      policy - initial InterestResultPolicy to set.
      Throws:
      IllegalArgumentException - if the given policy is not a valid type.
      See Also:
    • isReceiveValues

      public boolean isReceiveValues()
      Returns the type of values received by the listener.
      Returns:
      the receiveValues
    • setReceiveValues

      public void setReceiveValues(boolean receiveValues)
      Switches between the different entities received by the listener.
      Parameters:
      receiveValues - the receiveValues to set
    • getType

      public Interest.Type getType()
      Returns the type of interest registration (e.g. based on KEY or Regex).
      Returns:
      a Interest.Type determining the type of interest.
      See Also:
    • setType

      public void setType(Interest.Type type)
      Set the type of interest registration (e.g. based on KEY or Regex).
      Parameters:
      type - Interest.Type qualifying the type of interest.
      See Also:
    • isKeyType

      public boolean isKeyType()
      Determines whether this Interest is a KEY interest registration.
      Returns:
      a boolean value indicating whether this is KEY interest.
      See Also:
    • isRegexType

      public boolean isRegexType()
      Determines whether this Interest is a REGEX interest registration.
      Returns:
      a boolean value indicating whether this is REGEX interest.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asType

      public Interest asType(Interest.Type type)
      Builder method to specify the type of interest registration.
      Parameters:
      type - Interest.Type of interest registration.
      Returns:
      this Interest.
      See Also:
    • makeDurable

      public Interest makeDurable()
      Builder method to mark this Interest as durable.
      Returns:
      this Interest.
      See Also:
    • receivesValues

      public Interest receivesValues(boolean receiveValues)
      Builder method to set whether the interest event notifications will receive values along with keys.
      Parameters:
      receiveValues - boolean to indicate that value should be sent along with keys on interest event notifications.
      Returns:
      this Interest.
      See Also:
    • usingPolicy

      public Interest usingPolicy(InterestResultPolicy policy)
      Builder method to set the InterestResultPolicy used to initialize the cache.
      Parameters:
      policy - InterestResultPolicy.
      Returns:
      this Interest.
      See Also:
    • withKey

      public Interest withKey(K key)
      Builder method to express the key of interest.
      Parameters:
      key - key of interests.
      Returns:
      this Interest.
      See Also: