Community contributed extensions

AutoToString Mode

This is NOT a Play specific feature.

Rythm (starts from v1.0.0-20120716) provides an new feature called ATSM, the “Auto To String Mode”. This feature allows you to implement object’s toString() method without writing template.

public class Address {
    public String unitNo;
    public String streetNo;
    public String street;
    public String suburb;
    public String state;
    public String postCode;
    public String accessCode;
    @Override public String toString() {
        return Rythm.toString(this);

You can also pass option and style to fine tune to toString result:

@Override public String toString() {
    return Rythm.toString(this,

Rythm.toString() API

Rythm.toString() API accept 1 or 3 parameters:

public String toString(Object)

This API export object using default option and default style

public String toString(Object,

This API export object using specified option and style.

ToStringOption properties

Class<?> upToClass = null;

upToClass specify to up most level of parent class which properties will be exported. If it’s not specified, then it will expose properties up to java.lang.Object level

boolean appendTransient = false;

if appendTransient is set to true then transient properties or properties annotated with javax.persistence.Transient or will be output. By default these fields will NOT be output

boolean appendStatic = false;

if appendStatic is set to true then static properties will be output. By default they will NOT be output


com.greenlaw110.rythm.toString.ToStringStyle cloned org.apache.commons.lang3.builder.ToStringStyle

Skip certain properties

ATSM suppresses output properties annotated with com.greenlaw110.rythm.toString.NoExpose, or org.codehaus.jackson.annotate.JsonIgnore.


ATSM performance is slightly better (about 20% faster) than org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(Object). TSM however is 2x faster than it.

Compare to ReflectionToStringBuilder

Unlike ReflectionToStringBuilder which export all fields even private one, ATSM expose only public fields or properties exposed following java beans spec, i.e. properties like getXxx() or isXxx()

See also

  1. To string mode
  2. Rythm Manual Home Page