Example usage for org.apache.commons.lang3.builder EqualsBuilder reflectionEquals

List of usage examples for org.apache.commons.lang3.builder EqualsBuilder reflectionEquals

Introduction

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

Prototype

public static boolean reflectionEquals(final Object lhs, final Object rhs, final boolean testTransients) 

Source Link

Document

This method uses reflection to determine if the two Objects are equal.

It uses AccessibleObject.setAccessible to gain access to private fields.

Usage

From source file:org.segrada.session.Identity.java

@Override
public boolean equals(Object that) {
    return that != null && this.getClass() == that.getClass()
            && EqualsBuilder.reflectionEquals(this, that, "name");
}

From source file:org.springframework.data.solr.repository.ITestSimpleSolrRepository.java

@Test
public void testBeanLifecyle() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    ExampleSolrBean savedBean = repository.save(toInsert);

    Assert.assertSame(toInsert, savedBean);

    Assert.assertTrue(repository.exists(savedBean.getId()));

    ExampleSolrBean retrieved = repository.findOne(savedBean.getId());
    Assert.assertNotNull(retrieved);//  w w  w .  j  av a  2  s .co m
    Assert.assertTrue(EqualsBuilder.reflectionEquals(savedBean, retrieved, new String[] { "version" }));

    Assert.assertEquals(1, repository.count());

    Assert.assertTrue(repository.exists(savedBean.getId()));

    repository.delete(savedBean);

    Assert.assertEquals(0, repository.count());
    retrieved = repository.findOne(savedBean.getId());
    Assert.assertNull(retrieved);
}

From source file:org.springframework.data.solr.repository.ITestSimpleSolrRepository.java

@Test
public void testListFunctions() {
    int objectCount = 100;
    List<ExampleSolrBean> toInsert = new ArrayList<ExampleSolrBean>(objectCount);
    for (int i = 0; i < 100; i++) {
        toInsert.add(createExampleBeanWithId(Integer.toString(i)));
    }//w  ww .  j a  va 2  s  .c om

    repository.save(toInsert);

    Assert.assertEquals(objectCount, repository.count());

    int counter = 0;
    for (ExampleSolrBean retrievedBean : repository.findAll()) {
        Assert.assertTrue(EqualsBuilder.reflectionEquals(toInsert.get(counter), retrievedBean,
                new String[] { "version" }));

        counter++;
        if (counter > objectCount) {
            Assert.fail("More beans return than added!");
        }
    }

    repository.delete(toInsert.get(0));
    Assert.assertEquals(99, repository.count());

    repository.deleteAll();

    Assert.assertEquals(0, repository.count());
}

From source file:org.vader.ecm.domain.Document.java

@Override
public boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, EXTERNAL_FIELDS);
}

From source file:org.vader.ecm.domain.DocumentTemplate.java

@Override
public boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, "id");
}

From source file:ru.anr.base.domain.api.models.RequestModel.java

/**
 * {@inheritDoc}/* ww  w .j  av a2s .  co m*/
 */
@Override
public boolean equals(Object obj) {

    return EqualsBuilder.reflectionEquals(this, obj, EXCLUDED_FIELDS);
}

From source file:yoyo.framework.standard.shared.AbstractValueObject.java

/**
 * {@inheritDoc}/*from  ww w . ja  va 2 s  . c om*/
 * <p>
 * ????????????????(transient)????
 * </p>
 */
@Override
public boolean sameValueAs(final T other) {
    return EqualsBuilder.reflectionEquals(this, other, false);
}