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:com.alibaba.doris.admin.web.configer.module.action.NodeManageAction.java

public boolean isLegalMigrate(String IP, String targetSequence) {
    Map<String, String> checkMap = new HashMap<String, String>();
    List<PhysicalNodeDO> nodeList = adminNodeService.queryNomalPhysicalNodesByIP(IP);
    if (nodeList != null && nodeList.size() > 0) {
        checkMap.put(IP, Integer.toString(nodeList.get(0).getSerialId()));
    }//from ww  w.  j ava2  s  . c o m
    if (Integer.parseInt(targetSequence) > 0 && Integer.parseInt(targetSequence) < 9 && checkMap.get(IP) != null
            && !StringUtils.equals(checkMap.get(IP), targetSequence)) {
        return false;
    } else {
        checkMap.put(IP, targetSequence);
    }
    return true;
}

From source file:com.mirth.connect.model.ncpdp.NCPDPReference.java

public String getDescription(String key, String version) {
    if (StringUtils.equals(version, VERSION_D0)) {
        return MapUtils.getString(NCPDPD0map, key, StringUtils.EMPTY);
    } else {//from   ww  w.ja  v  a2 s  .  co m
        return MapUtils.getString(NCPDP51map, key, StringUtils.EMPTY);
    }
}

From source file:com.pawelniewiadomski.jira.openid.authentication.servlet.OAuthCallbackServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (!licenseProvider.isValidLicense()) {
        templateHelper.render(request, response, "OpenId.Templates.invalidLicense");
        return;/* w  w  w  . jav  a2 s  .  c  o m*/
    }

    final String cid = request.getParameter("cid");
    final OpenIdProvider provider;
    try {
        provider = openIdDao.findByCallbackId(cid);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }

    if (provider != null) {
        try {
            final OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
            final String state = (String) request.getSession()
                    .getAttribute(AuthenticationService.STATE_IN_SESSION);
            if (!StringUtils.equals(state, oar.getState())) {
                templateHelper.render(request, response, "OpenId.Templates.invalidState",
                        ImmutableMap.<String, Object>of("providerName", provider.getName()));
                return;
            }

            final OAuth2ProviderType providerType = (OAuth2ProviderType) providerTypeFactory
                    .getProviderTypeById(provider.getProviderType());
            final Either<Pair<String, String>, String> userOrError = providerType
                    .getUsernameAndEmail(oar.getCode(), provider, request);

            if (userOrError.isLeft()) {
                Pair<String, String> usernameAndEmail = userOrError.left().get();
                authenticationService.showAuthentication(request, response, provider, usernameAndEmail.first(),
                        usernameAndEmail.second());
            } else {
                templateHelper.render(request, response, "OpenId.Templates.errorWrapper",
                        ImmutableMap.<String, Object>of("content", userOrError.right().get()));
            }
            return;
        } catch (Exception e) {
            if (e instanceof OAuthProblemException) {
                templateHelper.render(request, response, "OpenId.Templates.oauthError",
                        ImmutableMap.<String, Object>of("providerName", provider.getName(), "errorMessage",
                                e.getMessage()));
            } else {
                log.error("OpenID verification failed", e);
                templateHelper.render(request, response, "OpenId.Templates.error");
            }
            return;
        }
    }

    templateHelper.render(request, response, "OpenId.Templates.error");
}

From source file:com.funambol.framework.tools.beans.SimpleNotCloneableBean.java

@Override
public boolean equals(Object o) {
    if (!(o instanceof SimpleCloneableBean)) {
        return false;
    }/* www .  ja va2  s  .c o  m*/
    SimpleNotCloneableBean clBean = (SimpleNotCloneableBean) o;
    return (StringUtils.equals(prop1, clBean.prop1) && StringUtils.equals(prop2, clBean.prop2));
}

From source file:com.netflix.spinnaker.halyard.config.validate.v1.FieldValidator.java

private void validateFieldForSpinnakerVersion(ConfigProblemSetBuilder p, Node n) {
    DeploymentConfiguration deploymentConfiguration = n.parentOfType(DeploymentConfiguration.class);
    String spinnakerVersion = deploymentConfiguration.getVersion();
    if (spinnakerVersion == null) {
        return;/* w  w  w .  j  av a2s . c  o m*/
    }

    Class clazz = n.getClass();
    while (clazz != Object.class) {
        Class finalClazz = clazz;
        Arrays.stream(clazz.getDeclaredFields()).forEach(field -> {
            ValidForSpinnakerVersion annotation = field.getDeclaredAnnotation(ValidForSpinnakerVersion.class);
            try {
                field.setAccessible(true);
                Object v = field.get(n);
                boolean fieldNotValid = false;
                String invalidFieldMessage = "";
                String remediation = "";
                if (v != null && annotation != null) {
                    if (Versions.lessThan(spinnakerVersion, annotation.lowerBound())) {
                        fieldNotValid = true;
                        invalidFieldMessage = annotation.tooLowMessage();
                        remediation = "Use at least " + annotation.lowerBound()
                                + " (It may not have been released yet).";
                    } else if (!StringUtils.equals(annotation.upperBound(), "")
                            && Versions.greaterThanEqual(spinnakerVersion, annotation.upperBound())) {
                        fieldNotValid = true;
                        invalidFieldMessage = annotation.tooHighMessage();
                        remediation = "You no longer need this.";
                    }
                }

                // If the field was set to false, it's assumed it's not enabling a restricted feature
                if (fieldNotValid && (v instanceof Boolean) && !((Boolean) v)) {
                    fieldNotValid = false;
                }

                // If the field is a collection, it may be empty
                if (fieldNotValid && (v instanceof Collection) && ((Collection) v).isEmpty()) {
                    fieldNotValid = false;
                }

                if (fieldNotValid) {
                    p.addProblem(Problem.Severity.WARNING,
                            "Field " + finalClazz.getSimpleName() + "." + field.getName()
                                    + " not supported for Spinnaker version " + spinnakerVersion + ": "
                                    + invalidFieldMessage)
                            .setRemediation(remediation);
                }
            } catch (NumberFormatException /* Probably using nightly build */ e) {
                log.info("Nightly builds do not contain version information.");
            } catch (IllegalAccessException /* Probably shouldn't happen */ e) {
                log.warn("Error validating field " + finalClazz.getSimpleName() + "." + field.getName() + ": ",
                        e);
            }
        });
        clazz = clazz.getSuperclass();
    }
}

From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.MemberLookupCompleter.java

@Override
public List<CompletionItem> getCompletionItems(Document document, String filter, int startOffset,
        int caretOffset) {
    List<CompletionItem> ret = new ArrayList<>();
    try {//from w ww .j a v  a2 s  .  co m
        String text = document.getText(0, caretOffset);
        List<String> variables = resolveVariable(filter, text);
        // if the filter is not the complete variable, we first autocomplete the actual variable
        for (String variable : variables) {
            if (!StringUtils.equals(filter, variable)) {
                ret.add(new BasicCompletionItem(variable, true, startOffset, caretOffset));
            }
        }
        // otherwise we lookup the defined class and return all of it's members
        if (ret.isEmpty()) {
            Set<String> items = resolveClass(filter, text, document);
            for (String item : items) {
                if (StringUtils.startsWith(item, filter)) {
                    ret.add(new BasicCompletionItem(item, false, startOffset, caretOffset));
                }
            }
        }
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
    }
    return ret;
}

From source file:com.xx_dev.apn.proxy.remotechooser.ApnProxyRemoteChooser.java

private static ApnProxyRemoteRule getApplyRemoteRule(String host) {
    for (ApnProxyRemoteRule remoteRule : ApnProxyConfig.getConfig().getRemoteRuleList()) {
        for (String originalHost : remoteRule.getOriginalHostList()) {
            if (StringUtils.equals(originalHost, host) || StringUtils.endsWith(host, "." + originalHost)) {
                return remoteRule;
            }//from   ww w  . j  a va  2s  .  c o m
        }
    }

    return null;
}

From source file:au.org.ala.delta.ui.GenericSearchController.java

@Override
public boolean findNext(SearchOptions options) {

    if (!StringUtils.equals(_lastResultTerm, options.getSearchTerm())) {
        _lastResult = null;//w w w  .  j a  v a2s. co  m
        _lastResultTerm = null;
    }

    int delta = options.getSearchDirection() == SearchDirection.Forward ? 1 : -1;

    int startFrom = getSelectedIndex() + 1;
    if (_lastResult != null) {
        int lastResultIndex = getIndexOf(_lastResult) + 1;
        if (lastResultIndex == getSelectedIndex() + 1) {
            startFrom = lastResultIndex + delta;
        }
    }

    int size = getSearchableModel().size();

    if (startFrom < 1) {
        startFrom = options.isWrappedSearch() ? size : 1;
    } else if (startFrom > size) {
        startFrom = options.isWrappedSearch() ? 1 : size;
    }

    _predicate = createPredicate(options);

    T result = findImpl(_predicate, startFrom);
    if (result == null && _lastResult != null && !options.isWrappedSearch()) {
        selectItem(_lastResult);
    } else {
        _lastResult = result;
        _lastResultTerm = options.getSearchTerm();
    }

    return _lastResult != null;
}

From source file:com.example.license.LicenseUtil.java

@SuppressWarnings("unchecked")
public static LicenseData parseLicense(String secret, String license) {
    try {/*  www.  j  ava2  s .  c o m*/
        PublicKey pub_key = SerializableUtil.DeserializablePublicKey("");
        Map<String, String> _obj = convertToObjcet(RSAUtil.decrypt(license, pub_key), Map.class);
        LicenseData data = (LicenseData) convertToObjcet(DESUtil.decrypt(_obj.get("data"), _obj.get("secret")),
                LicenseData.class);
        if (StringUtils.equals(generateSecret(secret, data), _obj.get("secret"))) {
            return data;
        }
    } catch (JsonStr2ObjException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:info.magnolia.logging.AuditLoggingManager.java

public LogConfiguration getLogConfiguration(String action) {
    Iterator<LogConfiguration> iterator = this.logConfigurations.iterator();
    while (iterator.hasNext()) {
        final LogConfiguration trail = iterator.next();
        if (StringUtils.equals(trail.getName(), action)) {
            return trail;
        }//w  w  w . j  a  v  a2 s. c  o  m
    }
    return null;
}