Example usage for org.apache.commons.lang StringUtils equals

List of usage examples for org.apache.commons.lang StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equals.

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationCommon.java

/**
 * Compares two routes and outlines the differences
 * @param originalRoute the original route
 * @param newRoute the new route to compare with the original
 * @return the differences//ww w.  jav  a 2  s. co  m
 */
public static String findChanges(Route originalRoute, Route newRoute) {

    StringBuilder changes = new StringBuilder();
    List<RouteWaypoint> wp1 = originalRoute.getWaypoints();
    List<RouteWaypoint> wp2 = newRoute.getWaypoints();

    if (!StringUtils.equals(originalRoute.getName(), newRoute.getName())) {
        changes.append(
                String.format("Name changed from '%s' to '%s'\n", originalRoute.getName(), newRoute.getName()));
    }

    if (wp1.size() == wp2.size()) {

        for (int i = 0; i < wp1.size(); i++) {
            if (!equals(wp1.get(i).getPos(), wp2.get(i).getPos())) {
                changes.append("Wp " + (i + 1) + " new position\n");
            }

            if (newRoute.getEtas().get(i).getTime() != originalRoute.getEtas().get(i).getTime()) {
                changes.append("Wp " + (i + 1) + " ETA Changed from "
                        + Formatter.formatShortDateTimeNoTz(originalRoute.getEtas().get(i)) + " to "
                        + Formatter.formatShortDateTimeNoTz(newRoute.getEtas().get(i)) + "\n");
            }
        }

    } else {
        if (wp2.size() > wp1.size()) {
            changes.append((wp2.size() - wp1.size()) + " new waypoints added");
        } else {
            changes.append((wp1.size() - wp2.size()) + " new waypoints removed");
        }
    }

    if (changes.length() == 0) {
        changes.append("No changes in receieved route");
    }

    return changes.toString();
}

From source file:com.iggroup.oss.restdoclet.plugin.util.XmlUtils.java

/**
 * Returns the <i>first</i> child-element of a XML node with a particular
 * name.//www  .  j  av a 2  s.  c  o m
 * 
 * @param node the XML node.
 * @param name the name of the child-element.
 * @return the child-element or <code>null</code> if no child with the name
 *         was found.
 */
public static Element child(final Node node, final String name) {
    Element element = null;

    for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        if (node.getChildNodes().item(i).getNodeType() == ELEMENT_NODE) {
            final Element child = (Element) node.getChildNodes().item(i);

            if (StringUtils.equals(name, child.getNodeName())) {
                element = child;
                break;
            }
        }
    }
    return element;
}

From source file:com.edgenius.wiki.search.interceptor.AttachmentIndexInterceptor.java

@SuppressWarnings("unchecked")
public void afterReturning(Object retValue, Method method, Object[] args, Object target) throws Throwable {
    if (StringUtils.equals(method.getName(), PageService.uploadAttachments)) {
        String spaceUname = (String) args[0];
        String pageUuid = (String) args[1];
        List<FileNode> ret = (List<FileNode>) retValue;
        if (ret != null && ret.size() > 0) {
            for (FileNode attachment : ret) {
                log.info("JMS message send for Attachment index creating. File name: "
                        + attachment.getFilename());
                IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_INSERT_ATTACHMENT,
                        new Object[] { spaceUname, attachment });
                jmsTemplate.convertAndSend(queue, mqObj);
            }//from w w  w  .  ja v a  2s.c  o m
            if (Shell.enabled && Global.restServiceEnabled && pageUuid != null) {
                log.info("JMS message send for Attachment creating shell service.");
                IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_INSERT_ATTACHMENT_BATCH, pageUuid);
                jmsTemplate.convertAndSend(queue, mqObj);
            }
        }
    } else if (StringUtils.equals(method.getName(), PageService.removeAttachment)) {
        String pageUuid = (String) args[1];
        String nodeUuid = (String) args[2];
        String version = (String) args[3];
        log.info(
                "JMS message send for Attachment index remove. NodeUUID: " + nodeUuid + ". Version:" + version);
        IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_REMOVE_ATTACHMENT,
                new String[] { pageUuid, nodeUuid, version });
        jmsTemplate.convertAndSend(queue, mqObj);
    } else if (StringUtils.equals(method.getName(), PageService.updateAttachmentMetaData)) {
        FileNode ret = (FileNode) retValue;
        String spaceUname = (String) args[0];
        String pageUuid = (String) args[1];
        //only update name and comment of attachment, the attachment file body (extract content) won't be updated.
        if (ret != null) {
            IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_UPDATE_ATTACHMENT,
                    new Object[] { spaceUname, pageUuid, ret });
            jmsTemplate.convertAndSend(queue, mqObj);
        }
    }
}

From source file:io.kamax.mxisd.storage.ormlite.OrmLiteSqliteStorageBeanFactory.java

@PostConstruct
private void postConstruct() {
    if (StringUtils.equals("sqlite", storagecfg.getBackend())) {
        if (StringUtils.isBlank(cfg.getDatabase())) {
            throw new ConfigurationException("storage.provider.sqlite.database");
        }//  w w  w  . ja v  a2  s  .  c  o  m

        storage = new OrmLiteSqliteStorage(cfg.getDatabase());
    }
}

From source file:de.hybris.platform.b2bacceleratorservices.customer.impl.B2BCustomerEmailResolutionService.java

@Override
public String getEmailForCustomer(final CustomerModel customerModel) {
    validateParameterNotNullStandardMessage("customerModel", customerModel);

    if (customerModel instanceof B2BCustomerModel
            && StringUtils.equals(customerModel.getUid(), ((B2BCustomerModel) customerModel).getEmail())) {
        return ((B2BCustomerModel) customerModel).getEmail();
    }//from   ww  w  .  j  a va2  s. c o m

    return getDefaultCustomerEmailResolutionService().getEmailForCustomer(customerModel);
}

From source file:com.cyclopsgroup.waterview.richweb.RuntimeTree.java

/**
 * Create new runtime node//ww w  .j  a v a 2s .co m
 *
 * @param node
 * @return Runtime tree node
 */
public RuntimeTreeNode createRuntimeNode(TreeNode node) {
    boolean expanded = isExpanded(node.getId());
    boolean selected = StringUtils.equals(node.getId(), getSelected());
    return new RuntimeTreeNode(node, expanded, selected);
}

From source file:com.microsoft.alm.plugin.external.utils.WorkspaceHelper.java

/**
 * This method simply compares two lists of mappings to see if they represent the same mappings.
 * If so, the method returns false, if not, it returns true.
 *
 * @param mappings1//from  www.j a v  a  2s.  c o m
 * @param mappings2
 * @return
 */
public static boolean areMappingsDifferent(final List<Workspace.Mapping> mappings1,
        final List<Workspace.Mapping> mappings2) {
    if (mappings1 == mappings2) {
        // They are the same list (or both null)
        return false;
    }

    // Check for simple differences: one is null, or size is different
    if (mappings1 == null || mappings2 == null || mappings1.size() != mappings2.size()) {
        return true;
    }

    // Create a map of mappings1 for quick lookup
    final Map<String, Workspace.Mapping> map = getMappingsByServerPath(mappings1);
    // Go thru every mapping of mappings2 and see if it exists in the map and is exactly the same
    for (final Workspace.Mapping mapping2 : mappings2) {
        final Workspace.Mapping mapping1 = map.get(getServerPathKey(mapping2.getServerPath()));
        if (mapping1 == null) {
            return true;
        }
        if (mapping1.isCloaked() != mapping2.isCloaked()
                || !StringUtils.equals(mapping1.getLocalPath(), mapping2.getLocalPath())
                || !StringUtils.equals(mapping1.getServerPath(), mapping2.getServerPath())) {
            return true;
        }
    }

    // Nothing was different, so they must be the same
    return false;
}

From source file:gov.nih.nci.cabig.caaers.domain.dto.AeMergeDTO.java

public void copyChanges(AdverseEventDTO iae, AdverseEventDTO eae, AdverseEventDTO mergedAe) {
    List<String> diff = iae.diff(eae);
    if (diff.contains("term")) {
        if (mergedAe.getTerm().isSame(iae.getTerm()))
            merges[0] = 1;/*w  w  w.j  a va2s  . c om*/
        else
            merges[0] = 2;
    }
    if (diff.contains("grade")) {
        if (StringUtils.equals(iae.getGrade(), mergedAe.getGrade()))
            merges[1] = 1;
        else
            merges[1] = 2;
    }
    if (diff.contains("startDate")) {
        if (StringUtils.equals(iae.getStartDate(), mergedAe.getStartDate()))
            merges[2] = 1;
        else
            merges[2] = 2;
    }
    if (diff.contains("endDate")) {
        if (StringUtils.equals(iae.getEndDate(), mergedAe.getEndDate()))
            merges[3] = 1;
        else
            merges[3] = 2;
    }
    if (diff.contains("verbatim")) {
        if (StringUtils.equals(iae.getVerbatim(), mergedAe.getVerbatim()))
            merges[4] = 1;
        else
            merges[4] = 2;
    }
    if (diff.contains("whySerious")) {
        if (StringUtils.equals(iae.getWhySerious(), mergedAe.getWhySerious()))
            merges[5] = 1;
        else
            merges[5] = 2;
    }
    if (diff.contains("attribution")) {
        if (StringUtils.equals(iae.getAttribution(), mergedAe.getAttribution()))
            merges[6] = 1;
        else
            merges[6] = 2;
    }
}

From source file:com.daimler.spm.b2bacceleratoraddon.forms.AdvancedSearchForm.java

public boolean isCatalogSearchResultType() {
    return StringUtils.equals(searchResultType, "catalog");
}

From source file:io.kamax.mxisd.threepid.notification.GenericNotificationHandler.java

protected void process(List<A> connectors, List<B> generators) {
    generator = generators.stream().filter(o -> StringUtils.equals(getGeneratorId(), o.getId())).findFirst()
            .orElseThrow(() -> new ConfigurationException(
                    getMedium() + " notification generator [" + getGeneratorId() + "] could not be found"));

    connector = connectors.stream().filter(o -> StringUtils.equals(getConnectorId(), o.getId())).findFirst()
            .orElseThrow(() -> new ConfigurationException(
                    getMedium() + " sender connector [" + getConnectorId() + "] could not be found"));
}