Over a million developers have joined DZone.

JAU: Java Annotation Based Utilities


I am glad to announce the first stable beta ;-) of the JAU library (http://code.google.com/p/jau/). Version 0.6 implements the following methods using annotations (and works for POJOs):

  • equals
  • hashCode
  • toString
  • compareTo
  • copy/clone
  • toMap/fromMap (this one creates a java.util.Map with object properties as entries)

Here is a sample use case:

import com.googlecode.jau.*;

public class UserData implements Comparable, Cloneable {
private String firstName;
private String secondName;
private Date birthDate;
private String login;

@JAUEquals // not really necessary. All fields are included by default
private String[] rights = new String[] {"view"};

private javax.swing.event.EventListenerList listeners = new javax.swing.event.EventListenerList();

// constructor omitted

public boolean equals(Object obj) {
return JAU.equals(this, obj);

public int hashCode() {
return JAU.hashCode(this);

public String toString() {
return JAU.toString(this);

public int compareTo(Object obj) {
return JAU.compare(this, obj);

public UserData clone() throws CloneNotSupportedException {
UserData r = (UserData) super.clone(this);
JAU.copy(this, r);
return r;

For example, the output for

JAU.toString(new String[][] {{"a", "b"}, {"1", "2"}})

would be

java.lang.String[][java.lang.String["a", "b"], java.lang.String["1", "2"]]

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}