JavaUtils is a library of Java utility classes and packages.


javautils Miscellaneous utility classes.
javautils.collections Utilities for manipulating collections.
javautils.dispensers Dispenser framework and library. Framework for functional objects.
javautils.graph Utilities for manipulating graphs.
javautils.graph.adt Interfaces for graphs.
javautils.graph.templates Template Methods [Gamma1995] for graph algorithms.
javautils.graph.testing Utilities for testing graph algorithms.
javautils.holders Holder classes for primitives types.
javautils.jdbc Utilities for dealing with JDBC.
javautils.maps Type safe maps for convenience.


JavaUtils is a library of Java utility classes and packages. Among other things, it contains utilities for functional programming.

About simple wrapper methods

Many methods in JavaUtils are very simple wrappers on Java API methods intended to make it convenient to perform frequently needed operations. These wrapper methods often translate checked exceptions to unchecked exceptions, using Exceptions.toThrowUnchecked(Throwable), and provide useful defaults for arguments. For example, Classes.newInstance(Class) is a very simple utility method for instantiating a class. The documentation of such methods is usually provided in the form of a pseudo code snippet that illustrates the semantics of the method. Such pseudo code snippets are not the implementation of the method.

Naming conventions

The classes and methods in the JavaUtils-library are named fairly systematically using a relatively small number of naming patterns.

Method naming

The naming conventions used in the JavaUtils-library are different from the Java naming conventions used by Sun. In JavaUtils, in general, method names start with a verb if the method is decisively imperative and the client calls the method explicitly for the side-effects of the method. On the other hand, methods that are functional, and do not have externally observable side-effects do not, in general, start with a verb. We feel that these conventions yield short and logical names that communicate the intentions of the methods well.

Class naming patterns

Example: AbstractTypedMap
An abstract class intended to be derived from to form a concrete class that implements some interface.
Example: BasicGraph
A basic implementation of some interface. Usually not intended to serve the needs of all users.
Example: GraphBuilder
A Builder [Gamma1995] is used for building complex objects.
Example: TestGraphConstants
An interface that defines useful constants. To use the constants, you can "implement" the interface to get convenient access to the constants.
Example: GraphContract
A Design-by-Contract [Meyer1997] Decorator [Gamma1995] for an interface.
Example: GraphDecorator
A basic forwarding Decorator [Gamma1995] for an interface that simply forwards all operations to the decorated object.
Example: IntHolder
A holder for a primitive value or reference. Used for storing primitive values in collections and to emulate lexical binding [Abelson1995] with anonymous inner classes.
Example: ObjectToIntMap
A class the represents a binary relation between keys and values.
*s (plural)
Example: Graphs
A class that contains static utility methods that implement algorithms relating to some concept.
Example: BfsTemplate
An abstract Template Method [Gamma1995] class.
Example: AlgsTest
An automated [JUnit] unit test class.
Example: ObjectToObjectToBoolean
A systematically named abstract class that represents an anonymous function [Abelson1995] (or a Strategy [Gamma1995]). The name reflects the type of the underlying function.


The following is a complete alphabetical listing of references made in the documentation. Please note that this documentation is not intended as an introduction to software design. The references point out to readily available software design, algorithm and programming texts whose material is general enough that it is not worth rephrasing here.

Structure and Interpretation of Computer Programs, 2nd. ed.
Abelson, Sussman and Sussman
ISBN 0-262-01153-0
Introduction to Algorithms, 2nd. ed.
Cormen, Leiserson, Rivest and Stein
ISBN 0-262-53196-8
Refactoring: Improving the Design of Existing Code
Martin Fowler
ISBN 0-201-48567-2
Design Patterns: Elements of Reusable Object-Oriented Software
Gamma, Helm, Johnson and Vlissides
ISBN 0-201-63361-2
"JUnit is a simple framework to write repeatable tests."
JUnit was originally designed by Erich Gamma and Kent Beck.
A Functional Pattern System for Object-Oriented Design
Thomas Kühne
ISBN 3-86064-770-9
Agile Software Development: Principles, Patterns, and Practices
Robert Cecil Martin
ISBN 0-13-597444-5
Object-Oriented Software Construction, 2nd. ed.
Bertrand Meyer
ISBN 0-13-629155-4
Pattern Languages of Program Design 3
Edited by Robert Martin, Dirk Riehle and Frank Buschmann.
ISBN 0-201-31011-2
The Boost Graph Library: User Guide and Reference Manual
Jeremy Siek, Lie-Quan Lee and Andrew Lumsdaine
ISBN 0-201-72914-8
Data Structures and Algorithm Analysis in C, 2nd. ed.
Mark Allen Weiss
ISBN 0-201-49840-5