Example usage for org.apache.commons.lang.builder ReflectionToStringBuilder setAppendTransients

List of usage examples for org.apache.commons.lang.builder ReflectionToStringBuilder setAppendTransients

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ReflectionToStringBuilder setAppendTransients.

Prototype

public void setAppendTransients(boolean appendTransients) 

Source Link

Document

Sets whether or not to append transient fields.

Usage

From source file:org.fornax.cartridges.sculptor.framework.domain.AbstractDomainObject.java

/**
 * Only "simple" types will be included in toString. Relations to other
 * domain objects can not be included since we don't know if they are
 * fetched and we don't wont toString to fetch them.
 * <p>//ww w .j  ava 2  s . c o m
 * More intelligent implementation can be done in subclasses if needed.
 * Subclasses may also override {@link #acceptToString(Field)}.
 * <p>
 * The
 */
@Override
public String toString() {
    try {
        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(this, toStringStyle()) {
            @Override
            protected boolean accept(Field f) {
                if (super.accept(f)) {
                    return acceptToString(f);
                } else {
                    return false;
                }
            }
        };
        builder.setAppendStatics(false);
        builder.setAppendTransients(true);
        return builder.toString();
    } catch (RuntimeException e) {
        // toString is only used for debug purpose and
        // eventual exceptions should not be "ignored"
        return "RuntimeException in " + getClass().getName() + ".toString():" + e.getMessage();
    }
}