Package com.illumon.iris.db.util.caching
Class C14nUtil
java.lang.Object
com.illumon.iris.db.util.caching.C14nUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Field Details
-
ENABLED
public static final boolean ENABLED -
CACHE
public static final com.fishlib.base.cache.OpenAddressedCanonicalizationCache CACHEAn CanonicalizationCache instance that can/should be used by "general" utilities that want to store canonicalized objects in memory. Shared by StringUtils.
-
-
Constructor Details
-
C14nUtil
public C14nUtil()
-
-
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
Make a SmartKey appropriate for values.- Parameters:
values
-- Returns:
- A canonicalized CanonicalizedSmartKey if all values are canonicalizable, else a new SmartKey
-
maybeMakeSmartKey
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
-