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:com.btoddb.chronicle.plunkers.hdfs.StorableAvroEvent.java

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

From source file:com.yahoo.pasc.PascRuntime.java

/**
 * Helper method to compare two objects for equality.
 * /*from w  w  w.ja  v  a  2  s .  c o m*/
 * If the objects implement EqualsDeep this method will use that interface.
 * 
 * @param o1 first object to compare
 * @param o2 second object to compare
 * @return true if both objects are equal
 */
@SuppressWarnings("unchecked")
public static <T> boolean compare(T o1, T o2) {
    if (o1 == null || o2 == null)
        return o1 == o2;
    if (o1 instanceof EqualsDeep) {
        return ((EqualsDeep<T>) o1).equalsDeep(o2);
    }

    return EqualsBuilder.reflectionEquals(o1, o2, false);
}

From source file:com.threewks.thundr.session.CookieSessionStore.java

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

From source file:com.francetelecom.clara.cloud.logicalmodel.LogicalEntity.java

@Override
public boolean equals(Object obj) {
    //See http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/builder/EqualsBuilder.html
    return EqualsBuilder.reflectionEquals(this, obj, EXCLUDED_EQUALS_FIELDS);
}

From source file:com.clueride.domain.account.member.Member.java

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

From source file:com.gihan.model.Payment.java

@Override
public boolean equals(Object obj) {
    if (!(obj instanceof Payment)) {
        return false;
    }//w  w  w. j  av a  2 s .  c o m
    return EqualsBuilder.reflectionEquals(obj, this, "id");
}

From source file:com.griddynamics.banshun.ExportTargetSource.java

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

From source file:com.mirth.connect.server.controllers.DefaultContextFactoryController.java

@Override
public synchronized void updateResources(List<LibraryProperties> resources, boolean startup) throws Exception {
    logger.debug("Updating resources: " + String.valueOf(resources));
    Set<String> resourceIds = new HashSet<String>();
    Set<String> resourceIdsToReload = new HashSet<String>();
    Set<String> globalScriptResourceIds = new HashSet<String>();

    for (LibraryProperties resource : resources) {
        resourceIds.add(resource.getId());
        LibraryProperties currentResource = libraryResources.get(resource.getId());

        // Only replace the resource if anything changed
        if (!resource.equals(currentResource)) {
            // Only reload the resource libraries if anything REALLY changed
            if (!EqualsBuilder.reflectionEquals(resource, currentResource,
                    new String[] { "name", "description", "includeWithGlobalScripts" })) {
                logger.debug("Resource " + String.valueOf(resource)
                        + " has changed (besides name / description / global scripts).");
                resourceIdsToReload.add(resource.getId());
            } else {
                logger.debug("Resource " + String.valueOf(resource) + " has changed.");
            }//from  www . j  a  v a2s .  c o  m

            LibraryPlugin plugin = (LibraryPlugin) extensionController.getResourcePlugins()
                    .get(resource.getPluginPointName());
            if (plugin != null) {
                try {
                    plugin.update(resource, startup);
                } catch (Exception e) {
                    logger.warn("Unable to update libraries: " + e.getMessage(), e);
                }
            } else {
                logger.error("Unable to update libraries: Plugin \"" + resource.getPluginPointName()
                        + "\" not found.");
            }

            libraryResources.put(resource.getId(), resource);
        }

        if (resource.isIncludeWithGlobalScripts()) {
            globalScriptResourceIds.add(resource.getId());
        }
    }

    for (LibraryProperties resource : libraryResources.values()
            .toArray(new LibraryProperties[libraryResources.size()])) {
        if (!resourceIds.contains(resource.getId())) {
            logger.debug("Removing resource " + String.valueOf(resource) + ".");
            resourceIdsToReload.add(resource.getId());
            libraryResources.remove(resource.getId());

            LibraryPlugin plugin = (LibraryPlugin) extensionController.getResourcePlugins()
                    .get(resource.getPluginPointName());
            if (plugin != null) {
                try {
                    plugin.remove(resource);
                } catch (Exception e) {
                    logger.warn("Unable to remove library resource: " + e.getMessage(), e);
                }
            } else {
                logger.error("Unable to remove library resource: Plugin \"" + resource.getPluginPointName()
                        + "\" not found.");
            }
        }
    }

    if (!this.globalScriptResourceIds.equals(globalScriptResourceIds)) {
        logger.debug("Global script resource IDs have changed: " + String.valueOf(globalScriptResourceIds));
        this.globalScriptResourceIds = globalScriptResourceIds;
    }

    reloadResources(resourceIdsToReload, startup);
}

From source file:com.yahoo.parsec.clients.ParsecAsyncHttpRequest.java

@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }//from  w w w . j ava2 s  .co m

    if (!(object instanceof ParsecAsyncHttpRequest)) {
        return false;
    }

    // Compare local fields except Ning request
    if (!EqualsBuilder.reflectionEquals(this, object, new String[] { "ningRequest" })) {
        return false;
    }

    // Compare Ning request fields
    return ParsecEqualsUtil.ningRequestEquals(ningRequest, ((ParsecAsyncHttpRequest) object).ningRequest);
}

From source file:com.btoddb.chronicle.Event.java

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