StringPrefixPartitionResolver (Apache Geode 1.9.2)
Date: 2019-10-15

org.apache.geode.cache.util

## Class StringPrefixPartitionResolver

- java.lang.Object
- - org.apache.geode.cache.util.StringPrefixPartitionResolver

- All Implemented Interfaces:
    CacheCallback, Declarable, PartitionResolver<String,Object>

      public class StringPrefixPartitionResolver
      extends Object
      implements PartitionResolver<String,Object>

  This partition resolver requires every key of the partitioned region to be an instance of String and to contain at least one "|" delimiter. The prefix, the substring of the key that precedes the first delimiter, is returned by getRoutingObject.
  Since:
    Geode 1.2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_DELIMITER` The default delimiter is "|".

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringPrefixPartitionResolver()` Creates a prefix resolver with the default delimiter.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.
    `boolean` | `equals(Object o)`
    `String` | `getName()` Returns the name of the PartitionResolver
    `Object` | `getRoutingObject(EntryOperation<String,Object> opDetails)` Returns the prefix of the String key that precedes the first "|" in the key.
    `int` | `hashCode()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Field Detail

    - #### DEFAULT_DELIMITER

          public static final String DEFAULT_DELIMITER

      The default delimiter is "|". Currently this class only uses the default delimiter but in a future release configuring the delimiter may be supported.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StringPrefixPartitionResolver

          public StringPrefixPartitionResolver()

      Creates a prefix resolver with the default delimiter.

  - ### Method Detail

    - #### getRoutingObject

          public Object getRoutingObject(EntryOperation<String,Object> opDetails)

      Returns the prefix of the String key that precedes the first "|" in the key.
      Specified by:
        `getRoutingObject` in interface `PartitionResolver<String,Object>`
      Parameters:
        `opDetails` - the detail of the entry operation e.g. `Region.get(Object)`
      Returns:
        object associated with entry operation which allows the Partitioned Region to store associated data together
      Throws:
        `ClassCastException` - if the key is not an instance of String
        `IllegalArgumentException` - if the key does not contain at least one "|".

    - #### getName

          public String getName()

      Description copied from interface: `PartitionResolver`
      Returns the name of the PartitionResolver
      Specified by:
        `getName` in interface `PartitionResolver<String,Object>`
      Returns:
        String name

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### close

          public void close()

      Description copied from interface: `CacheCallback`
      Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.

      Implementations should cleanup any external resources such as database connections. Any runtime exceptions this method throws will be logged.

      It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.

      Specified by:
        `close` in interface `CacheCallback`
      See Also:
        `RegionService.close()`, `Region.close()`, `Region.localDestroyRegion()`, `Region.destroyRegion()`, `AttributesMutator`