Example usage for org.apache.commons.lang3.builder ReflectionToStringBuilder toString

List of usage examples for org.apache.commons.lang3.builder ReflectionToStringBuilder toString

Introduction

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

Prototype

public static String toString(final Object object) 

Source Link

Document

Builds a toString value using the default ToStringStyle through reflection.

Usage

From source file:com.mb.framework.util.ObjectUtil.java

/**
 * This method is used for converting object to string
 * //  w ww .j  a v  a  2 s  .  co  m
 * @param obj
 * @return
 */
public static String objectToString(Object obj) {
    return ReflectionToStringBuilder.toString(obj);
}

From source file:com.paulwithers.bp106.DemoUtils.java

public static String convertObjectToString(final Object o) {
    String retVal_ = "";
    try {//from  ww  w .j a va2 s  . com
        retVal_ = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
            public String run() throws Exception {
                return ReflectionToStringBuilder.toString(o);
            }
        });
    } catch (AccessControlException e) {
        e.printStackTrace();
    } catch (PrivilegedActionException e) {
        e.printStackTrace();
    }
    return retVal_;
}

From source file:mesclasses.util.NodeUtil.java

public static void console(Object obj) {
    LOG.debug("[CONSOLE] " + ReflectionToStringBuilder.toString(obj).replaceAll(",", ",\r\n"));
}

From source file:com.newlandframework.rpc.serialize.RpcSerializeProtocol.java

public String toString() {
    ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);
    return ReflectionToStringBuilder.toString(this);
}

From source file:cn.ifengkou.hestia.model.MessageResponse.java

public String toString() {
    return ReflectionToStringBuilder.toString(this);
}

From source file:com.dangdang.example.elasticjob.spring.job.ParallelThroughputDataFlowElasticJobDemo.java

@Override
public List<Foo> fetchData(JobExecutionMultipleShardingContext shardingContext) {
    System.out.println("shardingContext ==>> " + ReflectionToStringBuilder.toString(shardingContext));
    printContext.printFetchDataMessage(shardingContext.getShardingItems());
    return fooRepository.findActive(shardingContext.getShardingItems());
}

From source file:com.makotogo.learn.javers.AppTest.java

@Test
public void testJaversDiff_ChangesSummary_Employee() {
    int numberOfEmployeesToCreate = 2;
    List<Employee> employees = classUnderTest.createEmployees(numberOfEmployeesToCreate);
    assertEquals(numberOfEmployeesToCreate, employees.size());
    Employee e1 = employees.get(0);/*from ww  w.  j a  va2s  .c om*/
    log.info("Employee 1: " + ReflectionToStringBuilder.toString(e1));
    Employee e2 = employees.get(1);
    log.info("Employee 2: " + ReflectionToStringBuilder.toString(e2));

    Diff diff = javers.compare(e1, e2);
    log.info("Changes summary: " + diff.prettyPrint());
}

From source file:com.makotojava.learn.jaxrs.util.RepositoryTest.java

@Test
public void testFindAll() {
    log.info("*** BEGIN TEST ***");
    ///*from  www .java  2s .c o  m*/
    // Get the repository size
    long repositorySize = repository.getRepositorySize();
    //
    // Retrieve all Person objects in the Repository
    List<Person> results = personFinder.findAll();
    //
    // Make sure the size reported matches the size
    /// of the collection we get back.
    assertEquals(repositorySize, results.size());
    //
    // Dump out the results (if log debug enabled)
    if (log.isDebugEnabled()) {
        for (Person person : results) {
            log.debug(ReflectionToStringBuilder.toString(person));
        }
    }
    log.info("*** END TEST ***");
}

From source file:com.makotogo.learn.javers.AppTest.java

@Test
public void testJaversDiff_ValueChange_Employee() {
    int numberOfEmployeesToCreate = 1;
    List<Employee> employees = classUnderTest.createEmployees(numberOfEmployeesToCreate);
    assertEquals(numberOfEmployeesToCreate, employees.size());
    Employee e1 = employees.get(0);/*www .j a  va 2  s .  com*/
    log.info("Employee 1: " + ReflectionToStringBuilder.toString(e1));
    Employee e2 = new Employee(e1.getName(), e1.getAge(), e1.getEyeColor(), e1.getGender(), e1.getTin(),
            e1.getEmployeeNumber());
    e2.setAge(e2.getAge() + 2);
    log.info("Employee 2: " + ReflectionToStringBuilder.toString(e2));
    Diff diff = javers.compare(e1, e2);
    List<ValueChange> changes = diff.getChangesByType(ValueChange.class);
    for (ValueChange change : changes) {
        log.info("Change => Property name/e1/e2: " + change.getPropertyName() + "/"
                + change.getLeft().toString() + "/" + change.getRight().toString());
    }
}

From source file:com.makotojava.learn.junit5.math.solution.YetAnotherUtilityTest.java

/**
 * Generates a custom message using ReflectionToStringBuilder.
 * /*from  w  ww  . j  a v  a  2s. c o  m*/
 * @param expectedResults
 *          The expected results
 * @param actualResults
 *          The actual results
 * @return String - the message
 */
private String generateCustomMessage(Object expectedResults, Object actualResults) {
    return "Expected " + ReflectionToStringBuilder.toString(expectedResults) + " but instead got: "
            + ReflectionToStringBuilder.toString(actualResults);
}