Rarely available and hard-to-write Java utilities, written correctly, and thoroughly tested (> 98% code coverage via JUnit tests).
To include in your project:
<dependency>
<groupId>com.cedarsoftware</groupId>
<artifactId>java-util</artifactId>
<version>1.52.0</version>
</dependency>
The java-util jar is about 150K in size.
YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.
Since Java 1.5, you can statically import classes. Using this technique with many of the classes below, it makes their methods directly accessible in your source code, keeping your source code smaller and easier to read. For example:
import static com.cedarsoftware.util.Converter.*;
will permit you to write:
...
Calendar cal = convertToCalendar("2019/11/17");
Date date = convertToDate("November 17th, 2019 4:45pm");
TimeStamp stamp = convertToTimeStamp(cal);
AtomicLong atomicLong = convertToAtomicLong("123128300")
String s = convertToString(atomicLong)
...
Included in java-util:
[]
byte[]
to HEX character []
and visa-versa.Set
that expands to a HashSet
when size() > compactSize()
.Set
that expands to a LinkedHashSet
when size() > compactSize()
.Set
that expands to a case-insensitive LinkedHashSet
when size() > compactSize()
.Set
that expands to a case-insensitive HashSet
when size() > compactSize()
.Set
that ignores case for Strings
contained within. Map
that expands to a HashMap
when size() > compactSize()
entries.Map
that expands to a LinkedHashMap
when size() > compactSize()
entries.Map
that expands to a case-insensitive LinkedHashMap
when size() > compactSize()
entries.Map
that expands to a case-insensitive HashMap
when size() > compactSize()
entries. Map
that ignores case when Strings
are used as keys.Map
class that tracks when the keys are accessed via .get()
or .containsKey()
. Provided by @seankellnerconvert("45.3", BigDecimal.class)
will convert the String
to a BigDecimal
. Works for all primitives, primitive wrappers, Date
, java.sql.Date
, String
, BigDecimal
, BigInteger
, AtomicBoolean
, AtomicLong
, etc. The method is very generous on what it allows to be converted. For example, a Calendar
instance can be input for a Date
or Long
. Examine source to see all possibilities.y/m/d
and m/d/y
ordering as well.equals()
method on an object if it has one, otherwise it will do a field-by-field equivalency check for non-transient fields. Has options to turn on/off using .equals()
methods that may exist on classes.Strings
, byte[]
, as well as making it easy to AES-128 encrypt Strings
and byte[]
's.Executor executor = new Executor(); executor.exec('ls -l');
Call executor.getOut()
to fetch the output, executor.getError()
retrieve error output. If a -1 is returned, there was an error.ByteArrayOutputStream
, FastByteArrayOutputStream
is 1) not synchronized
, and 2) allows access to it's internal byte[]
eliminating the duplication of the byte[]
when toByteArray()
is called.List
of Delta
objects which describe the difference between the two Object graphs. This Delta list can be played back, such that List deltas = GraphComparator.delta(source, target); GraphComparator.applyDelta(source, deltas)
will bring source up to match target. See JUnit test cases for example usage. This is a completely thorough graph difference (and apply delta), including support for Array
, Collection
, Map
, and object field differences..close()
method that handles exceptions for you.SimpleDateFormat
and thread safety (no reentrancy support).String
related tasks.See changelog.md for revision history.
By: John DeRegnaucourt and Ken Partlow