Class C14nUtil

java.lang.Object
com.illumon.iris.db.util.caching.C14nUtil

public class C14nUtil
extends Object
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static com.fishlib.base.cache.OpenAddressedCanonicalizationCache CACHE
    An CanonicalizationCache instance that can/should be used by "general" utilities that want to store canonicalized objects in memory.
    static boolean ENABLED  
  • Constructor Summary

    Constructors 
    Constructor Description
    C14nUtil()  
  • Method Summary

    Modifier and Type Method Description
    static com.fishlib.datastructures.util.SmartKey makeSmartKey​(Object... values)
    Make a SmartKey appropriate for values.
    static <T> T maybeCanonicalize​(T item)
    Canonicalize an object using the default CanonicalizationCache, if it's an instance of a known appropriate class.
    static <T> boolean maybeCanonicalizeAll​(T[] items)
    Canonicalizes an array of objects in-place using the default CanonicalizationCache, if they're instances of known appropriate classes.
    static Object maybeMakeSmartKey​(Object... values)
    If there is one value and it is null, return a special singleton smart key that we have created for this purpose.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ENABLED

      public static final boolean ENABLED
    • CACHE

      public static final com.fishlib.base.cache.OpenAddressedCanonicalizationCache CACHE
      An CanonicalizationCache instance that can/should be used by "general" utilities that want to store canonicalized objects in memory. Shared by StringUtils.
  • Constructor Details

  • Method Details

    • maybeCanonicalize

      public static <T> T maybeCanonicalize​(T item)
      Canonicalize an object using the default CanonicalizationCache, if it's an instance of a known appropriate class.
      Type Parameters:
      T -
      Parameters:
      item -
      Returns:
      null if item was null, else the canonicalized version of item if its class was eligible, else item
    • maybeCanonicalizeAll

      public static <T> boolean maybeCanonicalizeAll​(@NotNull T[] items)
      Canonicalizes an array of objects in-place using the default CanonicalizationCache, if they're instances of known appropriate classes. May canonicalize some items without canonicalizing all.
      Parameters:
      items -
      Returns:
      true if all non-null items were canonicalized, else false.
    • makeSmartKey

      public static com.fishlib.datastructures.util.SmartKey makeSmartKey​(Object... values)
      Make a SmartKey appropriate for values.
      Parameters:
      values -
      Returns:
      A canonicalized CanonicalizedSmartKey if all values are canonicalizable, else a new SmartKey
    • maybeMakeSmartKey

      public static Object maybeMakeSmartKey​(Object... values)
      If there is one value and it is null, return a special singleton smart key that we have created for this purpose. If there is one value and it is not null, hand it to maybeCanonicalize, which will either make a smart key out of it or return the value itself. Otherwise (if there are zero values or more than one value), then hand off to makeSmartKey which will make a CanonicalizedSmartKey (if possible) or a SmartKey (otherwise).
      Parameters:
      values - the value or values to turn into a key
      Returns:
      a potentially canonicalized key for use in a map