Example usage for org.apache.commons.lang.builder ToStringStyle SIMPLE_STYLE

List of usage examples for org.apache.commons.lang.builder ToStringStyle SIMPLE_STYLE

Introduction

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

Prototype

ToStringStyle SIMPLE_STYLE

To view the source code for org.apache.commons.lang.builder ToStringStyle SIMPLE_STYLE.

Click Source Link

Document

The simple toString style.

Usage

From source file:fr.xebia.demo.wicket.blog.data.Comment.java

@Override
public String toString() {
    ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE);
    builder.append("approved", approved);
    builder.append("author", author);
    builder.append("authorEmail", email);
    builder.append("date", date);
    builder.append("postId", postId);
    return builder.toString();
}

From source file:com.xtructure.xutil.test.MethodInfo.java

/**
 * Returns a cell with the parameters of the given child.
 * /*from   w  ww . j a  va  2s .co  m*/
 * @param child
 *            the child, the parameters of which should be returned
 * 
 * @return a cell with the parameters of the given child
 */
private final String paramCell(final InvocationInfo child) {
    return (ArrayUtils.isEmpty(child.getResult().getParameters()) ? "<td>&nbsp;</td>"
            : String.format("<td>%s</td>", //
                    new ToStringBuilder( //
                            child.getResult(), ToStringStyle.SIMPLE_STYLE) //
                                    .append(child.getResult().getParameters()) //
                                    .toString()));
}

From source file:fr.xebia.demo.wicket.blog.data.Post.java

@Override
public String toString() {
    ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE);
    builder.append("commentStatus", commentsAllowed);
    builder.append("date", date);
    builder.append("modified", modified);
    builder.append("postAuthor", author);
    builder.append("status", status);
    builder.append("title", title);
    return builder.toString();
}

From source file:com.likethecolor.alchemy.api.entity.RelationAlchemyEntityTest.java

@Test
public void testToString_Formatted() {
    final ToStringStyle style = ToStringStyle.SIMPLE_STYLE;
    final AlchemyAction action = getAction();
    final AlchemyObject object = getObject();
    final AlchemySubject subject = getSubject();

    final RelationAlchemyEntity entity = new RelationAlchemyEntity(action, object, subject);

    String expectedString = new ToStringBuilder(entity, style).append("action", action.toString(style))
            .append("object", object.toString(style)).append("subject", subject.toString(style)).toString();

    String actualString = entity.toString(style);

    assertEquals(expectedString, actualString);

    // null action
    entity.setAction(null);/*from   w  w  w  . j a va  2s  . c om*/

    expectedString = new ToStringBuilder(entity, style).append("action", (String) null)
            .append("object", object.toString(style)).append("subject", subject.toString(style)).toString();

    actualString = entity.toString(style);

    assertEquals(expectedString, actualString);

    // null object
    entity.setAction(action);
    entity.setObject(null);

    expectedString = new ToStringBuilder(entity, style).append("action", action.toString(style))
            .append("object", (String) null).append("subject", subject.toString(style)).toString();

    actualString = entity.toString(style);

    assertEquals(expectedString, actualString);

    // null subject
    entity.setAction(action);
    entity.setObject(object);
    entity.setSubject(null);

    expectedString = new ToStringBuilder(entity, style).append("action", action.toString(style))
            .append("object", object.toString(style)).append("subject", (String) null).toString();

    actualString = entity.toString(style);

    assertEquals(expectedString, actualString);
}

From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java

/**
 * <p>Outputs an array as a String handling <code>null</code>s.</p>
 *
 * <p>Multi-dimensional arrays are handled correctly, including
 * multi-dimensional primitive arrays.</p>
 *
 * <p>The format is that of Java source code, for example <code>{a,b}</code>.</p>
 * // w  ww .  ja  v a  2s  .com
 * @param array  the array to get a toString for, may be <code>null</code>
 * @param stringIfNull  the String to return if the array is <code>null</code>
 * @return a String representation of the array
 */
public static String toString(Object array, String stringIfNull) {
    if (array == null) {
        return stringIfNull;
    }
    return new ToStringBuilder(array, ToStringStyle.SIMPLE_STYLE).append(array).toString();
}

From source file:br.com.topsys.util.TSArrayUtil.java

/**
 * <p>//from   w w  w . j  a v  a  2  s .  c om
 * Outputs an array as a String handling <code>null</code>s.
 * </p>
 * 
 * <p>
 * Multi-dimensional arrays are handled correctly, including
 * multi-dimensional primitive arrays.
 * </p>
 * 
 * <p>
 * The format is that of Java source code, for example <code>{a,b}</code>.
 * </p>
 * 
 * @param array
 *            the array to get a toString for, may be <code>null</code>
 * @param stringIfNull
 *            the String to return if the array is <code>null</code>
 * @return a String representation of the array
 */
public static String toString(final Object array, final String stringIfNull) {
    if (array == null) {
        return stringIfNull;
    }
    return new ToStringBuilder(array, ToStringStyle.SIMPLE_STYLE).append(array).toString();
}

From source file:com.alibaba.otter.shared.common.utils.meta.DdlUtils.java

private static Table readTable(DatabaseMetaDataWrapper metaData, Map<String, Object> values)
        throws SQLException {
    String tableName = (String) values.get("TABLE_NAME");
    Table table = null;//from   w w w  . j  a va 2 s  . co  m

    if ((tableName != null) && (tableName.length() > 0)) {
        table = new Table();
        table.setName(tableName);
        table.setType((String) values.get("TABLE_TYPE"));
        table.setCatalog((String) values.get("TABLE_CAT"));
        table.setSchema((String) values.get("TABLE_SCHEM"));
        table.setDescription((String) values.get("REMARKS"));
        table.addColumns(readColumns(metaData, tableName));

        Collection<String> primaryKeys = readPrimaryKeyNames(metaData, tableName);

        for (Object key : primaryKeys) {
            Column col = table.findColumn((String) key, true);

            if (col != null) {
                col.setPrimaryKey(true);
            } else {
                throw new NullPointerException(String.format("%s pk %s is null - %s %s", tableName, key,
                        ToStringBuilder.reflectionToString(metaData, ToStringStyle.SIMPLE_STYLE),
                        ToStringBuilder.reflectionToString(values, ToStringStyle.SIMPLE_STYLE)));
            }
        }
    }

    return table;
}

From source file:org.apache.hadoop.hbase.rest.model.TestCellModel.java

@Test
public void testToString() throws Exception {
    String expectedColumn = ToStringBuilder.reflectionToString(COLUMN, ToStringStyle.SIMPLE_STYLE);

    CellModel cellModel = buildTestModel();
    System.out.println(cellModel);

    assertTrue(StringUtils.contains(cellModel.toString(), expectedColumn));
}

From source file:org.apache.hadoop.hbase.rest.model.TestRowModel.java

@Test
public void testToString() throws Exception {
    String expectedRowKey = ToStringBuilder.reflectionToString(ROW1, ToStringStyle.SIMPLE_STYLE);

    RowModel rowModel = buildTestModel();
    System.out.println(rowModel);

    assertTrue(StringUtils.contains(rowModel.toString(), expectedRowKey));
}

From source file:org.beanfuse.transfer.importer.Example.java

/**
 * @see java.lang.Object#toString()/*w  w  w.j  av a 2s  .co m*/
 */
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append("id", this.getId())
            .append("name", this.name).toString();
}