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.github.mrstampy.kitchensync.message.KiSyMessage.java

public boolean equals(Object o) {
    return EqualsBuilder.reflectionEquals(this, o, "origins");
}

From source file:com.google.code.jconfig.ConfigurationManager.java

/**
 * <p>// w  w w  .j a va2 s  .com
 *    Save the current configuration and send a notify only for changed ones
 *    and a new ones registered. Of course for the latter case, a listener
 *    had to be provided when calling <em>configureAndWatch<\em> method.
 * </p>
 * 
 * @throws ConfigurationException
 */
public void doConfigure() {
    Runnable runnable = new Runnable() {
        public void run() {
            try {
                ConfigurationInfo newConfigurationInfo = ConfigurationReaderFactory.read(filepath);
                Map<String, Object> confToBeNotified = new HashMap<String, Object>();
                Map<String, Object> curConfMap = currentConfigurationInfo.getConfigurationMap();
                if (newConfigurationInfo != null) {
                    for (Entry<String, Object> aNewConfEntry : newConfigurationInfo.getConfigurationMap()
                            .entrySet()) {
                        String key = aNewConfEntry.getKey();
                        Object theConf = aNewConfEntry.getValue();
                        /* only for new conf or changed configurations will be send a notify */
                        if ((curConfMap.containsKey(key)
                                && !EqualsBuilder.reflectionEquals(theConf, curConfMap.get(key), false))
                                || !curConfMap.containsKey(key)) {
                            confToBeNotified.put(key, theConf);
                        }
                    }

                    /* clear the old infos, put in the new ones cloned then release resources of the reader */
                    currentConfigurationInfo.clear();
                    currentConfigurationInfo.add(newConfigurationInfo);
                    newConfigurationInfo.clear();
                    /* notify changes to listener */
                    notifyListeners(confToBeNotified);
                    /* start watch on files */
                    WatchdogService.watch(instance, currentConfigurationInfo.getConfFileList(), delay);
                }
            } catch (ConfigurationParsingException e) {
                logger.error(e.getMessage(), e);
                WatchdogService.watch(instance, e.getFileParsedList(), delay);
            }
        }
    };

    poolExecutor.execute(runnable);
}

From source file:com.dell.asm.asmcore.asmmanager.client.devicegroup.DeviceGroup.java

@Override
public boolean equals(Object that) {
    return EqualsBuilder.reflectionEquals(this, that, new String[] { "createdDate", "updatedDate" });
}

From source file:com.feilong.test.User.java

public boolean equals(Object obj) {
    boolean reflectionEquals = EqualsBuilder.reflectionEquals(this, obj, "id");
    System.out.println(reflectionEquals);
    return reflectionEquals;
}

From source file:io.logspace.it.test.ReportTest.java

private void compareReports(Report expected, Report actual) {
    assertTrue("The loaded report does not equal the stored one.",
            EqualsBuilder.reflectionEquals(actual, expected, "timeSeriesDefinitions"));

    if (expected.getTimeSeriesDefinitions() == actual.getTimeSeriesDefinitions()) {
        return;/*  www. j  ava 2 s  .  co  m*/
    }

    assertEquals("The loaded report does not equal the stored one.",
            actual.getTimeSeriesDefinitions().getDefinitionCount(),
            expected.getTimeSeriesDefinitions().getDefinitionCount());

    for (int i = 0; i < actual.getTimeSeriesDefinitions().getDefinitionCount(); i++) {
        assertTrue("The loaded report does not equal the stored one.",
                EqualsBuilder.reflectionEquals(actual.getTimeSeriesDefinitions().getDefinition(i),
                        expected.getTimeSeriesDefinitions().getDefinition(i)));
    }
}

From source file:gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO.java

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

From source file:com.dell.asm.asmcore.asmmanager.client.deviceinventory.ManagedDevice.java

@Override
public boolean equals(Object that) {
    return EqualsBuilder.reflectionEquals(this, that, new String[] { "infraTemplateDate", "serverTemplateDate",
            "inventoryDate", "complianceCheckDate", "discoveredDate" });
}

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

@Override
public synchronized boolean updateChannel(Channel channel, ServerEventContext context, boolean override)
        throws ControllerException {
    // Never include code template libraries in the channel stored in the database
    channel.getCodeTemplateLibraries().clear();
    channel.clearDependencies();/* w ww.  j  a  v  a2s  .  co m*/

    /*
     * Methods that update the channel must be synchronized to ensure the channel cache and
     * database never contain different versions of a channel.
     */

    int newRevision = channel.getRevision();
    int currentRevision = 0;

    Channel matchingChannel = getChannelById(channel.getId());

    // If the channel exists, set the currentRevision
    if (matchingChannel != null) {
        /*
         * If the channel in the database is the same as what's being passed in, don't bother
         * saving it.
         * 
         * Ignore the channel revision and last modified date when comparing the channel being
         * passed in to the existing channel in the database. This will prevent the channel from
         * being saved if the only thing that changed was the revision and/or the last modified
         * date. The client/CLI take care of this by passing in the proper revision number, but
         * the API alone does not.
         */
        if (EqualsBuilder.reflectionEquals(channel, matchingChannel,
                new String[] { "lastModified", "revision" })) {
            return true;
        }

        currentRevision = matchingChannel.getRevision();

        // Use the larger nextMetaDataId to ensure a metadata ID will never be reused if an older version of a channel is imported or saved.
        channel.setNextMetaDataId(Math.max(matchingChannel.getNextMetaDataId(), channel.getNextMetaDataId()));
    }

    /*
     * If it's not a new channel, and its version is different from the one in the database (in
     * case it has been changed on the server since the client started modifying it), and
     * override is not enabled
     */
    if ((currentRevision > 0) && (currentRevision != newRevision) && !override) {
        return false;
    } else {
        channel.setRevision(currentRevision + 1);
    }

    ArrayList<String> destConnectorNames = new ArrayList<String>(channel.getDestinationConnectors().size());

    for (Connector connector : channel.getDestinationConnectors()) {
        if (destConnectorNames.contains(connector.getName())) {
            throw new ControllerException("Destination connectors must have unique names");
        }
        destConnectorNames.add(connector.getName());
    }

    try {
        // If we are adding, then make sure the name isn't being used
        matchingChannel = getChannelByName(channel.getName());

        if (matchingChannel != null) {
            if (!channel.getId().equals(matchingChannel.getId())) {
                logger.error("There is already a channel with the name " + channel.getName());
                throw new ControllerException("A channel with that name already exists");
            }
        }

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", channel.getId());
        params.put("name", channel.getName());
        params.put("revision", channel.getRevision());
        params.put("channel", channel);

        // Put the new channel in the database
        if (getChannelById(channel.getId()) == null) {
            logger.debug("adding channel");
            SqlConfig.getSqlSessionManager().insert("Channel.insertChannel", params);
        } else {
            logger.debug("updating channel");
            SqlConfig.getSqlSessionManager().update("Channel.updateChannel", params);
        }

        // invoke the channel plugins
        for (ChannelPlugin channelPlugin : extensionController.getChannelPlugins().values()) {
            channelPlugin.save(channel, context);
        }

        return true;
    } catch (Exception e) {
        throw new ControllerException(e);
    }
}

From source file:gov.nih.nci.firebird.nes.person.NesPersonServiceBeanIntegrationTest.java

@Test
public void testRefreshNow() throws Exception {
    Person person = PersonFactory.getInstance().createWithoutExternalData();
    service.save(person);/*w w w .j  ava 2s. c  o m*/

    Person unSynchronizedPerson = PersonFactory.getInstanceWithId().create();
    unSynchronizedPerson.setExternalData(person.getExternalData());
    service.refreshNow(unSynchronizedPerson);

    Collection<String> excludes = Lists.newArrayList("id", "ctepId", "providerNumber", "lastNesRefresh");
    assertTrue(EqualsBuilder.reflectionEquals(person, unSynchronizedPerson, excludes));
}

From source file:gov.ca.cwds.data.persistence.cms.ExternalInterface.java

/**
 * {@inheritDoc}//from   w  ww  . jav a2  s . c  o m
 *
 * @see java.lang.Object#equals(java.lang.Object)
 */
@Override
public final boolean equals(Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj, false);
}