- Added Collection, Array, and EnumSet support to
Converter.
All of the prior supported types are now supported in within Collection, array, and EnumSet, including multiple dimensions.- Added
Number
as a destination type forConverter.
This is useful when using converter as a casting tool - casting toNumber
returns the same value back (if instance ofNumber
) or throws conversion exception. This covers all primitives, primitive wrappers,AtomicInteger
,AtomicLong
,BigInteger
, andBigDecimal
.
- Fix issue with field access
ClassUtilities.getClassLoader()
when in OSGi environment. Thank you @ozhelezniak-talend.- Added
ClassUtilities.getClassLoader(Class<?> c)
so that class loading was not confined to java-util classloader bundle. Thank you @ozhelezniak-talend.
ClassUtilities.getClassLoader()
added. This will safely return the correct class loader when running in OSGi, JPMS, or neither.ArrayUtilities.createArray()
added. This method accepts a variable number of arguments and returns them as an array of typeT[].
- Fixed bug when converting
Map
containing "time" key (and nodate
norzone
keys) with value tojava.sql.Date.
The millisecond portion was set to 0.
SealableMap, LRUCache,
andTTLCache
updated to useConcurrentHashMapNullSafe
internally, to simplify their implementation, as they no longer have to implement the null-safe work,ConcurrentHashMapNullSafe
does that for them.- Added
ConcurrentNavigableMapNullSafe
andConcurrentNavigableSetNullSafe
- Allow for
SealableNavigableMap
andSealableNavigableSet
to handle null- Added support for more old timezone names (EDT, PDT, ...)
- Reverted back to agrona 1.22.0 (testing scope only) because it uses class file format 52, which still works with JDK 1.8
- Missing comma in OSGI support added in pom.xml file. Thank you @ozhelezniak.
TestGraphComparator.testNewArrayElement
updated to reliable compare results (not depdendent on a Map that could return items in differing order). Thank you @wtrazs
- Introducing
TTLCache
: a cache with a configurable minimum Time-To-Live (TTL). Entries expire and are automatically removed after the specified TTL. Optionally, set amaxSize
to enable Least Recently Used (LRU) eviction. EachTTLCache
instance can have its own TTL setting, leveraging a sharedScheduledExecutorService
for efficient resource management. To ensure proper cleanup, callTTLCache.shutdown()
when your application or service terminates.- Introducing
ConcurrentHashMapNullSafe
: a drop-in replacement forConcurrentHashMap
that supportsnull
keys and values. It uses internal sentinel values to managenulls,
providing a seamless experience. This frees users fromnull
handling concerns, allowing unrestricted key-value insertion and retrieval.LRUCache
updated to use a singleScheduledExecutorService
across all instances, regardless of the individual time settings. Call the staticshutdown()
method onLRUCache
when your application or service is ending.
ClassUtilities.addPermanentClassAlias()
- add an alias that.forName()
can use to instantiate class (e.g. "date" forjava.util.Date
)ClassUtilities.removePermanentClassAlias()
- remove an alias that.forName()
can no longer use.- Updated build plug-in dependencies.
LRUCache
improved garbage collection handling to avoid gc Nepotism issues by nulling out node references upon eviction. Pointed out by Ben Manes.- Combined
ForkedJoinPool
andScheduledExecutorService
into use of onlyScheduledExecutorServive,
which is easier for user. The user can supplynull
or their own scheduler. In the case ofnull
, one will be created and theshutdown()
method will terminate it. If the user supplies aScheduledExecutorService
it will be used, but not shutdown when theshutdown()
method is called. This allowsLRUCache
to work well in containerized environments.
LRUCache
updated to support both "locking" and "threaded" implementation strategies.
LRUCache
re-written so that it operates in O(1) forget(),
put(),
andremove()
methods without thread contention. When items are placed into (or removed from) the cache, it schedules a cleanup task to trim the cache to its capacity. This means that it will operate as fast as aConcurrentHashMap,
yet shrink to capacity quickly after modifications.
- Fixed potential memory leak in
LRUCache.
- Added
nextPermutation
toMathUtilities.
- Added
size(),
,isEmpty(),
andhasContent
toCollectionUtilities.
- Added
SealableList
which provides aList
(orList
wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via aSupplier<Boolean>.
This moves the immutability control outside the list and ensures that all views on theList
respect the sealed-ness. One master supplier can control the immutability of many collections.- Added
SealableSet
similar to SealableList but withSet
nature.- Added
SealableMap
similar to SealableList but withMap
nature.- Added
SealableNavigableSet
similar to SealableList but withNavigableSet
nature.- Added
SealableNavigableMap
similar to SealableList but withNavigableMap
nature.- Updated
ConcurrentList
to support wrapping anyList
and making it thread-safe, including all view APIs:iterator(),
listIterator(),
listIterator(index).
The no-arg constructor creates aConcurrentList
ready-to-go. The constructor that takes aList
parameter constructor wraps the passed in list and makes it thread-safe.- Renamed
ConcurrentHashSet
toConcurrentSet.
- Added
ClassUtilities.doesOneWrapTheOther()
API so that it is easy to test if one class is wrapping the other.- Added
StringBuilder
andStringBuffer
toStrings
to theConverter.
Eliminates special cases for.toString()
calls where generalizedconvert(src, type)
is being used.
- Added
ConcurrentList,
which implements a thread-safeList.
Provides all API support except forlistIterator(),
however, it implementsiterator()
which returns an iterator to a snapshot copy of theList.
- Added
ConcurrentHashSet,
a trueSet
which is a bit easier to use thanConcurrentSkipListSet,
which as aNavigableSet
andSortedSet,
requires each element to beComparable.
- Performance improvement: On
LRUCache,
removed unnecessaryCollections.SynchronizedMap
surrounding the internalLinkedHashMap
as the concurrent protection offered byReentrantReadWriteLock
is all that is needed.
- Performance improvement:
Converter
instance creation is faster due to the code no longer copying the static default table. Overrides are kept in separate variable.- New capability added:
MathUtilities.parseToMinimalNumericType()
which will parse a String number into a Long, BigInteger, Double, or BigDecimal, choosing the "smallest" datatype to represent the number without loss of precision.- New conversions added to convert from
Map
toStringBuilder
andStringBuffer.
- pom.xml file updated to support both OSGi Bundle and JPMS Modules.
- module-info.class resides in the root of the .jar but it is not referenced.
- Updated to allow the project to be compiled by versions of JDK > 1.8 yet still generate class file format 52 .class files so that they can be executed on JDK 1.8+ and up.
- Incorporated @AxataDarji GraphComparator changes that reduce cyclomatic code complexity (refactored to smaller methods)
- Performance improvement:
DeepEquals.deepHashCode()
- now usingIdentityHashMap()
for cycle (visited) detection.- Modernization:
UniqueIdGenerator
- updated to useLock.lock()
andLock.unlock()
instead ofsynchronized
keyword.- Using json-io 4.14.1 for cloning object in "test" scope, eliminates cycle depedencies when building both json-io and java-util.
- All 687 conversions supported are now 100% cross-product tested. Converter test suite is complete.
- All 686 conversions supported are now 100% cross-product tested. There will be more exception tests coming.
- Added
ReflectionUtils.getDeclaredFields()
which gets fields from aClass
, including anEnum
, and special handles enum so that system fields are not returned.
Converter
- Enum test added. 683 combinations.
DateUtilities
- now supports timezone offset with seconds component (rarer than seeing a bald eagle in your backyard).Converter
- many more tests added...682 combinations.
- Fixed compatibility issues with
StringUtilities.
Method parameters changed from String to CharSequence broke backward compatibility. Linked jars are bound to method signature at compile time, not at runtime. Added both methods where needed. Removed methods with "Not" in the name.- Fixed compatibility issue with
FastByteArrayOutputStream.
The.getBuffer()
API was removed in favor of toByteArray(). Now both methods exist, leavinggetBuffer()
for backward compatibility.- The Converter "Everything" test updated to track which pairs are tested (fowarded or reverse) and then outputs in order what tests combinations are left to write.
Converter
has had significant expansion in the types that it can convert between, about 670 combinations. In addition, you can add your own conversions to it as well. Call theConverter.getSupportedConversions()
to see all the combinations supported. Also, you can useConverter
instance-based now, allowing it to have different conversion tables if needed.DateUtilities
has had performance improvements (> 35%), and adds a new.parseDate()
API that allows it to return aZonedDateTime.
See the updated Javadoc on the class for a complete description of all the formats it supports. Normally, you do not need to use this class directly, as you can useConverter
to convert betweenDates
,Calendars
, and the new Temporal classes likeZonedDateTime,
Duration,
Instance,
as well as Strings.FastByteArrayOutputStream
updated to matchByteArrayOutputStream
API. This means that.getBuffer()
is.toByteArray()
and.clear()
is now.reset().
FastByteArrayInputStream
added. MatchesByteArrayInputStream
API.- Bug fix:
SafeSimpleDateFormat
to properly format dates having years with fewer than four digits.- Bug fix: SafeSimpleDateFormat .toString(), .hashCode(), and .equals() now delegate to the contain SimpleDataFormat instance. We recommend using the newer DateTimeFormatter, however, this class works well for Java 1.8+ if needed.
- Added ClassUtilities. This class has a method to get the distance between a source and destination class. It includes support for Classes, multiple inheritance of interfaces, primitives, and class-to-interface, interface-interface, and class to class.
- Added LRUCache. This class provides a simple cache API that will evict the least recently used items, once a threshold is met.
Added
FastReader
andFastWriter.
FastReader
can be used instead of the JDKPushbackReader(BufferedReader)).
It is much faster with no synchronization and combines both. It also tracks line[getLine()]
and column[getCol()]
position monitoring for0x0a
which it can be queried for. It also can be queried for the last snippet read:getLastSnippet().
Great for showing parsing error messages that accurately point out where a syntax error occurred. Make sure you use a new instance per each thread.FastWriter
can be used instead of the JDKBufferedWriter
as it has no synchronization. Make sure you use a new Instance per each thread.
- Built with JDK 1.8 and runs with JDK 1.8 through JDK 21.
- The 2.2.x will continue to maintain JDK 1.8. The 3.0 branch [not yet created] will be JDK11+
- Added tests to verify that
GraphComparator
andDeepEquals
do not count sorted order of Sets for equivalency. It does however, requireCollections
that are notSets
to be in order.
- ReflectionUtils skips static fields, speeding it up and remove runtime warning (field SerialVersionUID). Supports JDK's up through 21.
DeepEquals.deepEquals(a, b)
compares Sets and Maps without regards to order per the equality spec.- Updated all dependent libraries to latest versions as of 16 Sept 2023.
- Upgraded from Java 8 to Java 11.
- Updated
ReflectionUtils.getClassNameFromByteCode()
to handle up to Java 17class
file format.
- Fixed:
UniqueIdGenerator
now correctly gets last two digits of ID using 3 attempts - JAVA_UTIL_CLUSTERID (optional), CF_INSTANCE_INDEX, and finally using SecuritRandom for the last two digits.- Removed
log4j
in favor ofslf4j
andlogback
.
- Updated log4j dependencies to version
2.17.1
.
- Updated log4j dependencies to version
2.17.0
.
- Bug fix: Options (IGNORE_CUSTOM_EQUALS and ALLOW_STRINGS_TO_MATCH_NUMBERS) were not propagated inside containers\
- Bug fix: When progagating options the Set of visited ItemsToCompare (or a copy if it) should be passed on to prevent StackOverFlow from occurring.
- Performance Improvement:
DateUtilities
now using non-greedy matching for regex's within date sub-parts.- Performance Improvement:
CompactMap
updated to use non-copying iterator for all non-Sorted Maps.- Performance Improvement:
StringUtilities.hashCodeIgnoreCase()
slightly faster - calls JDK method that makes one less call internally.
- Performance Improvement: Anytime
CompactMap
/CompactSet
is copied internally, the destination map is pre-sized to correct size, eliminating growing underlying Map more than once.ReflectionUtils.getConstructor()
added. Fetches Constructor, caches reflection operation - 2nd+ calls pull from cache.
- Updated
DateUtilities
to handle sub-seconds precision more robustly.- Updated
GraphComparator
to add missing srcValue when MAP_PUT replaces existing value. @marcobjorge
Converter
now supportsLocalDate
,LocalDateTime
,ZonedDateTime
to/fromCalendar
,Date
,java.sql.Date
,Timestamp
,Long
,BigInteger
,BigDecimal
,AtomicLong
,LocalDate
,LocalDateTime
, andZonedDateTime
.
- Updated to require Java 1.8 or newer.
UniqueIdGenerator
will recognize Cloud FoundryCF_INSTANCE_INDEX
, in addition toJAVA_UTIL_CLUSTERID
as an environment variable or Java system property. This will be the last two digits of the generated unique id (making it cluster safe). Alternatively, the value can be the name of another environment variable (detected by not being parseable as an int), in which case the value of the specified environment variable will be parsed as server id within cluster (value parsed as int, mod 100).- Removed a bunch of Javadoc warnings from build.
- Updated to consume
log4j 2.13.3
- more secure.
ReflectionUtils
now caches the methods it finds byClassLoader
andClass
. Earlier, found methods were cached perClass
. This did not handle the case when multipleClassLoaders
were used to load the same class with the same method. UsingReflectionUtils
to locate thefoo()
method will find it inClassLoaderX.ClassA.foo()
(and cache it as such), and if asked to find it inClassLoaderY.ClassA.foo()
,ReflectionUtils
will not find it in the cache withClassLoaderX.ClassA.foo()
, but it will fetch it fromClassLoaderY.ClassA.foo()
and then cache the method with thatClassLoader/Class
pairing.DeepEquals.equals()
was not comparingBigDecimals
correctly. If they had different scales but represented the same value, it would returnfalse
. Now they are properly compared usingbd1.compareTo(bd2) == 0
.DeepEquals.equals(x, y, options)
has a new option. If you addALLOW_STRINGS_TO_MATCH_NUMBERS
to the options map, then if aString
is being compared to aNumber
(or vice-versa), it will convert theString
to aBigDecimal
and then attempt to see if the values still match. If so, then it will continue. If it could not convert theString
to aNumber
, or the convertedString
as aNumber
did not match,false
is returned.convertToBigDecimal()
now handles very largelongs
andAtomicLongs
correctly (before it returnedfalse
if thelongs
were greater than adouble's
max integer representation.)CompactCIHashSet
andCompactCILinkedHashSet
now return a newMap
that is sized tocompactSize() + 1
when switching from internal storage toHashSet
/LinkedHashSet
for storage. This is purely a performance enhancement.
New Sets:
CompactCIHashSet
added. ThisCompactSet
expands to a case-insensitiveHashSet
whensize() > compactSize()
.CompactCILinkedSet
added. ThisCompactSet
expands to a case-insensitiveLinkedHashSet
whensize() > compactSize()
.CompactLinkedSet
added. ThisCompactSet
expands to aLinkedHashSet
whensize() > compactSize()
.CompactSet
exists. ThisCompactSet
expands to aHashSet
whensize() > compactSize()
.New Maps:
CompactCILinkedMap
exists. ThisCompactMap
expands to a case-insensitiveLinkedHashMap
whensize() > compactSize()
entries.CompactCIHashMap
exists. ThisCompactMap
expands to a case-insensitiveHashMap
whensize() > compactSize()
entries.CompactLinkedMap
added. ThisCompactMap
expands to aLinkedHashMap
whensize() > compactSize()
entries.CompactMap
exists. ThisCompactMap
expands to aHashMap
whensize() > compactSize()
entries.
CompactCIHashMap
added. This is aCompactMap
that is case insensitive. When more thancompactSize()
entries are stored in it (default 80), it uses aCaseInsenstiveMap
HashMap
to hold its entries.CompactCILinkedMap
added. This is aCompactMap
that is case insensitive. When more thancompactSize()
entries are stored in it (default 80), it uses aCaseInsenstiveMap
LinkedHashMap
to hold its entries.- Bug fix:
CompactMap
entrySet()
andkeySet()
were not handling theretainAll()
,containsAll()
, andremoveAll()
methods case-insensitively when case-insensitivity was activated.Converter
methods that convert to byte, short, int, and long now accepted String decimal numbers. The decimal portion is truncated.
- Added
CompactSet
. Works similarly toCompactMap
with singleObject[]
holding elements until it crossescompactSize()
threshold.
ThisObject[]
is adjusted dynamically as objects are added and removed.
- Added
char
andCharacter
support toConvert.convert*()
- Added full Javadoc to
Converter
.- Performance improvement in
Iterator.remove()
for all ofCompactMap's
iterators:keySet().iterator()
,entrySet().iterator
, andvalues().iterator
.- In order to get to 100% code coverage with Jacoco, added more tests for
Converter
,CaseInsenstiveMap
, andCompactMap
.
Converter.convert2*()
methods added: Ifnull
passed in, primitive 'logical zero' is returned. Example:Converter.convert(null, boolean.class)
returnsfalse
.Converter.convertTo*()
methods: ifnull
passed in,null
is returned. Allows "tri-state" Boolean. Example:Converter.convert(null, Boolean.class)
returnsnull
.Converter.convert()
converts usingconvertTo*()
methods for primitive wrappers, andconvert2*()
methods for primitive classes.Converter.setNullMode()
removed.
CompactMap
now supports 4 stages of "growth", making it much smaller in memory than nearly anyMap
. After0
and1
entries, and between2
andcompactSize()
entries, the entries in theMap
are stored in anObject[]
(using same single member variable). The even elements the 'keys' and the odd elements are the associated 'values'. This array is dynamically resized to exactly match the number of stored entries. When more thancompactSize()
entries are used, theMap
then uses theMap
returned from the overrideablegetNewMap()
api to store the entries. In all cases, it maintains the underlying behavior of theMap
.- Updated to consume
log4j 2.13.1
CompactMap
now supports case-insensitivity when using String keys. By default, it is case sensitive, but you can override theisCaseSensitive()
method and returnfalse
. This allows you to returnTreeMap(String.CASE_INSENSITIVE_ORDER)
orCaseInsensitiveMap
from thegetNewMap()
method. With these overrides, CompactMap is now case insensitive, yet still 'compact.'Converter.setNullMode(Converter.NULL_PROPER | Converter.NULL_NULL)
added to allow control over hownull
values are converted. By default, passing anull
value into primitiveconvert*()
methods returns the primitive form of0
orfalse
.
If the static methodConverter.setNullMode(Converter.NULL_NULL)
is called it will change the behavior of the primitiveconvert*()
methods returnnull
.
CompactMap
introduced.
CompactMap
is aMap
that strives to reduce memory at all costs while retaining speed that is close toHashMap's
speed. It does this by using only one (1) member variable (of typeObject
) and changing it as theMap
grows. It goes from single value, to a singleMap Entry
, to anObject[]
, and finally it uses aMap
(user defined).CompactMap
is especially small when0
or1
entries are stored in it. Whensize()
is from2
tocompactSize()
, then entries are stored internally in singleObject[]
. If thesize() > compactSize()
then the entries are stored in a regularMap
.// If this key is used and only 1 element then only the value is stored protected K getSingleValueKey() { return "someKey"; } // Map you would like it to use when size() > compactSize(). HashMap is default protected abstract Map<K, V> getNewMap(); // If you want case insensitivity, return true and return new CaseInsensitiveMap or TreeMap(String.CASE_INSENSITIVE_PRDER) from getNewMap() protected boolean isCaseInsensitive() { return false; } // 1.45.0 // When size() > than this amount, the Map returned from getNewMap() is used to store elements. protected int compactSize() { return 100; } // 1.46.0
This class only has one (1) member variable of type
Object
. If there are no entries in it, then the value of that member variable takes on a pointer (points to sentinel value.)If the entry has a key that matches the value returned from
getSingleValueKey()
then there is no key stored and the internal single member points to the value (still retried with 100% proper Map semantics).If the single entry's key does not match the value returned from
getSingleValueKey()
then the internal field points to an internalClass
CompactMapEntry
which contains the key and the value (nothing else). Again, all APIs still operate the same.In this case, the single member variable points to a single Object[] that contains all the keys and values. The keys are in the even positions, the values are in the odd positions (1 up from the key). [0] = key, [1] = value, [2] = next key, [3] = next value, and so on. The Object[] is dynamically expanded until size() > compactSize(). In addition, it is dynamically shrunk until the size becomes 1, and then it switches to a single Map Entry or a single value.
In this case, the single member variable points to a
Map
instance (supplied bygetNewMap()
API that user supplied.) This allowsCompactMap
to work with nearly allMap
types. This Map supports null for the key and values, as long as the Map returned by getNewMap() supports null keys-values.
CaseInsensitiveMap(Map orig, Map backing)
added for allowing precise control of whatMap
instance is used to back theCaseInsensitiveMap
. For example,Map originalMap = someMap // has content already in it Map ciMap1 = new CaseInsensitiveMap(someMap, new TreeMap()) // Control Map type, but not initial capacity Map ciMap2 = new CaseInsensitiveMap(someMap, new HashMap(someMap.size())) // Control both Map type and initial capacity Map ciMap3 = new CaseInsensitiveMap(someMap, new Object2ObjectOpenHashMap(someMap.size())) // Control initial capacity and use specialized Map from fast-util.
CaseInsensitiveMap.CaseInsensitiveString()
constructor madepublic
.
CaseInsensitiveMap.putObject(Object key, Object value)
added for placing objects into typed Maps.
CaseInsensitiveMap.plus()
and.minus()
added to support+
and-
operators in languages like Groovy.CaseInsenstiveMap.CaseInsensitiveString
(static
inner Class) is nowpublic
.
- Added
ReflectionUtils.getNonOverloadedMethod()
to support reflectively fetching methods with only Class and Method name available. This implies there is no method overloading.
- Added
ReflectionUtils.call(bean, methodName, args...)
to allow one-step reflective calls. See Javadoc for any limitations.- Added
ReflectionUtils.call(bean, method, args...)
to allow easy reflective calls. This version requires obtaining theMethod
instance first. This approach allows methods with the same name and number of arguments (overloaded) to be called.- All
ReflectionUtils.getMethod()
APIs cache reflectively located methods to significantly improve performance when using reflection.- The
call()
methods throw the target of the checkedInvocationTargetException
. The checkedIllegalAccessException
is rethrown wrapped in a RuntimeException. This allows making reflective calls without having to handle these two checked exceptions directly at the call point. Instead, these exceptions are usually better handled at a high-level in the code.
- Enhancement:
UniqueIdGenerator
now generates the long ids in monotonically increasing order. @HonorKnight- Enhancement: New API [
getDate(uniqueId)
] added toUniqueIdGenerator
that when passed an ID that it generated, will return the time down to the millisecond when it was generated.
TestUtil.assertContainsIgnoreCase()
andTestUtil.checkContainsIgnoreCase()
APIs added. These are generally used in unit tests to check error messages for key words, in order (as opposed to doing.contains()
on a string which allows the terms to appear in any order.)- Build targets classes in Java 1.7 format, for maximum usability. The version supported will slowly move up, but only based on necessity allowing for widest use of java-util in as many projects as possible.
Converter.convert()
now bi-directionally supportsCalendar.class
, e.g. Calendar to Date, SqlDate, Timestamp, String, long, BigDecimal, BigInteger, AtomicLong, and vice-versa.UniqueIdGenerator.getUniqueId19()
is a new API for getting 19 digit unique IDs (a fulllong
value) These are generated at a faster rate (10,000 per millisecond vs. 1,000 per millisecond) than the original (18-digit) API.- Hardcore test added for ensuring concurrency correctness with
UniqueIdGenerator
.- Javadoc beefed up for
UniqueIdGenerator
.- Updated public APIs to have proper support for generic arguments. For example Class<T>, Map<?, ?>, and so on. This eliminates type casting on the caller's side.
ExceptionUtilities.getDeepestException()
added. This API locates the source (deepest) exception.
DeepEquals.deepEquals()
, when comparingMaps
, theMap.Entry
type holding theMap's
entries is no longer considered in equality testing. In the past, a custom Map.Entry instance holding the key and value could cause inquality, which should be ignored. @AndreyNudkoConverter.convert()
now uses parameterized types so that the return type matches the passed inClass
parameter. This eliminates the need to cast the return value ofConverter.convert()
.MapUtilities.getOrThrow()
added which throws the passed inThrowable
when the passed in key is not within theMap
. @ptjuanramos
- Performance Improvement:
CaseInsensitiveMap
, when created from anotherCaseInsensitiveMap
, re-uses the internalCaseInsensitiveString
keys, which are immutable.- Bug fix:
Converter.convertToDate(), Converter.convertToSqlDate(), and Converter.convertToTimestamp()
all threw aNullPointerException
if the passed in content was an empty String (of 0 or more spaces). When passed in NULL to these APIs, you get back null. If you passed in empty strings or bad date formats, an IllegalArgumentException is thrown with a message clearly indicating what input failed and why.
- Enhancement:
DeepEquals.deepEquals(a, b options)
added. The new options map supports a keyDeepEquals.IGNORE_CUSTOM_EQUALS
which can be set to a Set of String class names. If any of the encountered classes in the comparison are listed in the Set, and the class has a custom.equals()
method, it will not be called and instead adeepEquals()
will be performed. If the value associated to theIGNORE_CUSTOM_EQUALS
key is an empty Set, then no custom.equals()
methods will be called, except those on primitives, primitive wrappers,Date
,Class
, andString
.
- Bug fix:
DeepEquals.deepEquals(a, b)
could report equivalent unorderedCollections
/Maps
as not equal if the items in theCollection
/Map
had the same hash code.
Converter
updated to exposeconvertTo*()
APIs that allow converting to a known type.
- Renamed
AdjustableFastGZIPOutputStream
toAdjustableGZIPOutputStream
.
- Add
AdjustableFastGZIPOutputStream
so that compression level can be adjusted.
ByteArrayOutputStreams
converted toFastByteArrayOutputStreams
internally.
- Removed test dependencies on Guava
- Rounded out APIs on
FastByteArrayOutputStream
- Added APIs to
IOUtilities
.
- Enhancement:
IOUtilities.compressBytes(FastByteArrayOutputStream, FastByteArrayOutputStream)
added.
- Enhancement:
FastByteArrayOutputStream.getBuffer()
API made public.
- Enhancement:
FastByteArrayOutputStream
added. Similar to JDK class, but withoutsynchronized
and access to innerbyte[]
allowed without duplicating thebyte[]
.
- Enhancement:
Converter.convert()
now supportsenum
toString
- Bug fix: The internal class
CaseInsensitiveString
did not implementComparable
interface correctly.
- Enhancement: added
getClassNameFromByteCode()
API toReflectionUtils
.
- Enhancement: The Delta object returned by
GraphComparator
implementsSerializable
for those usingObjectInputStream
/ObjectOutputStream
. Provided by @metlaivan (Ivan Metla)
- Performance improvement:
CaseInsensitiveMap/Set
internally addsStrings
toMap
without using.toLowerCase()
which eliminates creating a temporary copy on the heap of theString
being added, just to get its lowerCaseValue.- Performance improvement:
CaseInsensitiveMap/Set
uses less memory internally by caching the hash code as anint
, instead of anInteger
.StringUtilities.caseInsensitiveHashCode()
API added. This allows computing a case-insensitive hashcode from aString
without any object creation (heap usage).
Converter.convert()
- performance improved using class instance comparison versus classString
name comparison.CaseInsensitiveMap/Set
- performance improved.CaseInsensitiveString
(internal) short-circuits on equality check if hashCode() [cheap runtime cost] is not the same. Also, all method returning true/false to detect ifSet
orMap
changed rely on size() instead of contains.
Converter.convert()
API update: When a mutable type (Date
,AtomicInteger
,AtomicLong
,AtomicBoolean
) is passed in, and the destination type is the same, rather than return the instance passed in, a copy of the instance is returned.
- Added
GraphComparator
which is used to compute the difference (delta) between two object graphs. The generatedList
of Delta objects can be 'played' against the source to bring it up to match the target. Very useful in transaction processing systems.
- Added
Executor
which is used to execute Operating System commands. For example,Executor exector = new Executor(); executor.exec("echo This is handy"); assertEquals("This is handy", executor.getOut().trim());
- bug fix:
CaseInsensitiveMap
, when passed aLinkedHashMap
, was inadvertently using a HashMap instead.
CaseInsensitiveMap
intentionally does not retain 'not modifiability'.CaseInsensitiveSet
intentionally does not retain 'not modifiability'.
- Failed release. Do not use.
TrackingMap
changed so thatget(anyKey)
always marks it as keyRead. Same forcontainsKey(anyKey)
.CaseInsensitiveMap
has a constructor that takes aMap
, which allows it to take on the nature of theMap
, allowing for case-insensitiveConcurrentHashMap
, sortedCaseInsensitiveMap
, etc. The 'Unmodifiable'Map
nature is intentionally not taken on. The passed inMap
is not mutated.CaseInsensitiveSet
has a constructor that takes aCollection
, nwhich allows it to take on the nature of theCollection
, allowing for sortedCaseInsensitiveSets
. The 'unmodifiable'Collection
nature is intentionally not taken on. The passed inSet
is not mutated.
TrackingMap
changed so that an existing key associated to null counts as accessed. It is valid for manyMap
types to allow null values to be associated to the key.TrackingMap.getWrappedMap()
added so that you can fetch the wrappedMap
.
TrackingMap
changed so that.put()
does not mark the key as accessed.
TrackingMap
added. Create this map around any type of Map, and it will track which keys are accessed via .get(), .containsKey(), or .put() (when put overwrites a value already associated to the key). Provided by @seankellner.
- Bug fix:
CaseInsensitiveMap.entrySet()
- callingentry.setValue(k, v)
while iterating the entry set, was not updating the underlying value. This has been fixed and test case added.
- The order in which system properties are read versus environment variables via the
SystemUtilities.getExternalVariable()
method has changed. System properties are checked first, then environment variables.
- Fixed issue in
DeepEquals.deepEquals()
where a Container type (Map
orCollection
) was being compared to a non-container - the result of this comparison was inconsistent. It is always false if a Container is compared to a non-container type (anywhere within the object graph), regardless of the comparison order A, B versus comparing B, A.
StringUtilities.createUtf8String(byte[])
API added which is used to easily create UTF-8 strings without exception handling code.StringUtilities.getUtf8Bytes(String s)
API added which returns a byte[] of UTF-8 bytes from the passed in Java String without any exception handling code required.ByteUtilities.isGzipped(bytes[])
API added which returns true if thebyte[]
represents gzipped data.IOUtilities.compressBytes(byte[])
API added which returns the gzipped version of the passed inbyte[]
as abyte[]
IOUtilities.uncompressBytes(byte[])
API added which returns the original byte[] from the passed in gzippedbyte[]
.- JavaDoc issues correct to support Java 1.8 stricter JavaDoc compilation.
UrlUtilities
now allows for per-threaduserAgent
andreferrer
as well as maintains backward compatibility for setting these values globally.StringUtilities
getBytes()
andcreateString()
now allow null as input, and return null for output for null input.- Javadoc updated to remove errors flagged by more stringent Javadoc 1.8 generator.
- Support added for
Timestamp
inConverter.convert()
null
can be passed intoConverter.convert()
for primitive types, and it will return their logical 0 value (0.0f, 0.0d, etc.). For primitive wrappers, atomics, etc, null will be returned.- "" can be passed into
Converter.convert()
and it will set primitives to 0, and the object types (primitive wrappers, dates, atomics) to null.String
will be set to "".
- Added full support for
AtomicBoolean
,AtomicInteger
, andAtomicLong
toConverter.convert(value, AtomicXXX)
. Any reasonable value can be converted to/from these, including Strings, Dates (AtomicLong
), allNumber
types.IOUtilities.flush()
now supportsXMLStreamWriter
UIUtilities.close()
now supportsXMLStreamReader
andXMLStreamWriter
in addition toCloseable
.Converter.convert(value, type)
- a value of null is supported for the numeric types, boolean, and the atomics - in which case it returns their "zero" value and false for boolean. For date and String return values, a null input will return null. Thetype
parameter must not be null.
- In
Converter.convert(value, type)
, the value is trimmed of leading / trailing white-space if it is a String and the type is aNumber
.
- Added
Converter.convert()
API. Allows converting instances of one type to another. Handles all primitives, primitive wrappers,Date
,java.sql.Date
,String
,BigDecimal
,BigInteger
,AtomicInteger
,AtomicLong
, andAtomicBoolean
. Additionally, input (from) argument acceptsCalendar
.- Added static
getDateFormat()
toSafeSimpleDateFormat
for quick access to thread local formatter (per formatString
).
- Switched to use Log4J2 () for logging.
- bug fix:
CaseInsensitiveMap.keySet()
was only initializing the iterator once. IfkeySet()
was called a 2nd time, it would no longer work.
- bug fix:
CaseInsensitiveSet()
, the return value foraddAll()
,returnAll()
, andretainAll()
was wrong in some cases.
EncryptionUtilities
- Added byte[] APIs. Makes it easy to encrypt/decryptbyte[]
data.pom.xml
had extraneous characters inadvertently added to the file - these are removed.- 1.13.1 & 13.12 - issues with sonatype
DateUtilities
- Day of week allowed (properly ignored).DateUtilities
- First (st), second (nd), third (rd), and fourth (th) ... supported.DateUtilities
- The default toString() standard date / time displayed by the JVM is now supported as a parseable format.DateUtilities
- Extra whitespace can exist within the date string.DateUtilities
- Full time zone support added.DateUtilities
- The date (or date time) is expected to be in isolation. Whitespace on either end is fine, however, once the date time is parsed from the string, no other content can be left (prevents accidently parsing dates from dates embedded in text).UrlUtilities
- Removed proxy from calls toURLUtilities
. These are now done through the JVM.
UniqueIdGenerator
uses 99 as the cluster id when the JAVA_UTIL_CLUSTERID environment variable or System property is not available. This speeds up execution on developer's environments when they do not specifyJAVA_UTIL_CLUSTERID
.- All the 1.11.x features rolled up.
UrlUtilities
- separated out call that resolvesres://
to a public API to allow for wider use.
- Updated so headers can be set individually by the strategy (
UrlInvocationHandler
)InvocationHandler
set to always usesPOST
method to allow additionalHTTP
headers.
- Better IPv6 support (
UniqueIdGenerator
)- Fixed
UrlUtilities.getContentFromUrl()
(byte[]
) no longer setting upSSLFactory
whenHTTP
protocol used.
UrlInvocationHandler
,UrlInvocationStrategy
- Updated to allow more generalized usage. Pass in your implementation ofUrlInvocationStrategy
which allows you to set the number of retry attempts, fill out the URL pattern, set up the POST data, and optionally set/get cookies.- Removed dependency on json-io. Only remaining dependency is Apache commons-logging.
- Issue #3 fixed:
DeepEquals.deepEquals()
allows similarMap
(orCollection
) types to be compared without returning 'not equals' (false). Example,HashMap
andLinkedHashMap
are compared on contents only. However, compare aSortedSet
(likeTreeMap
) toHashMap
would fail unless the Map keys are in the same iterative order.- Tests added for
UrlUtilities
- Tests added for
Traverser
- Added wildcard to regex pattern to
StringUtilities
. This API turns a DOS-like wildcard pattern (where * matches anything and ? matches a single character) into a regex pattern useful inString.matches()
API.
- Floating-point allow difference by epsilon value (currently hard-coded on
DeepEquals
. Will likely be optional parameter in future version).
MathUtilities
added. Currently, variable lengthminimum(arg0, arg1, ... argn)
andmaximum()
functions added. Available forlong
,double
,BigInteger
, andBigDecimal
. These cover the smaller types.CaseInsensitiveMap
andCaseInsensitiveSet
keySet()
andentrySet()
are faster as they do not make a copy of the entries. Internally,CaseInsensitiveString
caches it's hash, speeding up repeated access.StringUtilities levenshtein()
anddamerauLevenshtein()
added to compute edit length. See Wikipedia to understand of the difference between these two algorithms. Currently recommend usinglevenshtein()
as it uses less memory.- The Set returned from the
CaseInsensitiveMap.entrySet()
now contains mutable entry's (value-side). It had been using an immutable entry, which disallowed modification of the value-side during entry walk.
UrlUtilities
, fixed issue where the default settings for the connection were changed, not the settings on the actual connection.
ReflectionUtilities
has newgetClassAnnotation(classToCheck, annotation)
API which will return the annotation if it exists within the classes super class hierarchy or interface hierarchy. Similarly, thegetMethodAnnotation()
API does the same thing for method annotations (allow inheritance - class or interface).
CaseInsensitiveMap
methodskeySet()
andentrySet()
return Sets that are identical to how the JDK returns 'view' Sets on the underlying storage. This means that all operations, besidesadd()
andaddAll()
, are supported.CaseInsensitiveMap.keySet()
returns aSet
that is case insensitive (not aCaseInsensitiveSet
, just aSet
that ignores case). Iterating thisSet
properly returns each originally stored item.
- Fixed
CaseInsensitiveMap() removeAll()
was not removing when accessed viakeySet()
- Added
DateUtilities
. See description above.
- Added "res" protocol (resource) to
UrlUtilities
to allow files from classpath to easily be loaded. Useful for testing.
UrlUtilities.getContentFromUrl() / getContentFromUrlAsString()
- removed hard-coded proxy server name
UrlUtilities.getContentFromUrl() / getContentFromUrlAsString()
- allow content to be fetched asString
or binary (byte[]
).
SystemUtilities
added. New API to fetch value from environment or System propertyUniqueIdGenerator
- checks for environment variable (or System property) JAVA_UTIL_CLUSTERID (0-99). Will use this if set, otherwise last IP octet mod 100.
- Added:
UrlUtilities.getContentFromUrl()
- Added
CaseInsensitiveSet
.
- Fixed:
CaseInsensitiveMap's iterator.remove()
method, it did not remove items.- Fixed:
CaseInsensitiveMap's equals()
method, it required case to match on keys.
- Initial version