Class Normalizer<T>
java.lang.Object
org.microbean.assign.Normalizer<T>
- Type Parameters:
T- the type of object to be normalized
An experimental, simple, mutable, concurrent cache of objects.
- Author:
- Laird Nelson
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newNormalizer.Normalizer(ConcurrentMap<Object, T> cache) Creates a newNormalizer. -
Method Summary
Modifier and TypeMethodDescriptionfinal TNormalizes the suppliedelementsuch that if thisNormalizeralready has an equivalent cached element, the cached element is returned, and, if it does not, the suppliedelementis cached indefinitely and returned.final TNormalizes the suppliedelementsuch that if thisNormalizeralready has an equivalent cached element, the cached element is returned, and, if it does not, the suppliedelementis cached indefinitely and returned.
-
Constructor Details
-
Normalizer
-
Normalizer
Creates a newNormalizer.- Parameters:
cache- aConcurrentMapthat will be used as the internal cache; may benullin which case a default, unbounded, initially empty implementation will be used instead
-
-
Method Details
-
normalize
Normalizes the suppliedelementsuch that if thisNormalizeralready has an equivalent cached element, the cached element is returned, and, if it does not, the suppliedelementis cached indefinitely and returned.- Parameters:
element- the element to normalize; may benullin which casenullis returned- Returns:
- the supplied
elementor a previously cached equivalent element - See Also:
-
normalize
Normalizes the suppliedelementsuch that if thisNormalizeralready has an equivalent cached element, the cached element is returned, and, if it does not, the suppliedelementis cached indefinitely and returned.- Parameters:
element- the element to normalize; may benullin which casenullis returnedextra- additional data to include in equality comparisons; may benull; ignored ifelementisnull- Returns:
- the supplied
elementor a previously cached equivalent element
-