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.att.aro.core.settings.impl.JvmSettings.java

@Override
public String getAttribute(String name) {
    if (!StringUtils.equals("Xmx", name)) {
        throw new IllegalArgumentException("Not a valid property:" + name);
    }// w  ww.j a  v  a  2 s  .co m
    Path path = Paths.get(CONFIG_FILE_PATH);
    if (!path.toFile().exists()) {
        return DEFAULT_MEM;
    }
    try (Stream<String> lines = Files.lines(path)) {
        List<String> values = lines.filter((line) -> StringUtils.contains(line, name))
                .collect(Collectors.toList());
        if (values == null || values.isEmpty()) {
            LOGGER.error("No xmx entries on vm options file");
            return DEFAULT_MEM;
        } else {
            return values.get(values.size() - 1).replace("-Xmx", "").replace("m", "");
        }
    } catch (IOException e) {
        String message = "Counldn't read vm options file";
        LOGGER.error(message, e);
        throw new ARORuntimeException(message, e);
    }
}

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

/**
 * Equals./*w  w  w . ja v  a  2 s  .com*/
 *
 * @param priorTherapy the prior therapy
 * @param other the other
 * @return true, if successful
 */
public boolean equals(PriorTherapy priorTherapy, String other) {
    return StringUtils.equals(this.other, other) && ObjectUtils.equals(this.priorTherapy, priorTherapy);
}

From source file:com.backelite.sonarqube.swift.coverage.CoberturaReportParser.java

private static void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder)
        throws XMLStreamException {
    SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
    while (line.getNext() != null) {
        int lineId = Integer.parseInt(line.getAttrValue("number"));
        try {/*from  w ww.j a  v  a2s.c o m*/
            builder.setHits(lineId, (int) ParsingUtils.parseNumber(line.getAttrValue("hits"), Locale.ENGLISH));
        } catch (ParseException e) {
            throw new XmlParserException(e);
        }

        String isBranch = line.getAttrValue("branch");
        String text = line.getAttrValue("condition-coverage");
        if (StringUtils.equals(isBranch, "true") && StringUtils.isNotBlank(text)) {
            String[] conditions = StringUtils.split(StringUtils.substringBetween(text, "(", ")"), "/");
            builder.setConditions(lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
        }
    }
}

From source file:com.apexxs.neonblack.solr.Searcher.java

public List<DetectedLocation> search(List<DetectedLocation> locs) {
    Queries queries = new Queries();

    for (DetectedLocation loc : locs) {
        if (loc.detectedBy.equals("NER")) {
            List<GeoNamesEntry> geonames = new ArrayList<>();
            String queryString = getQueryString(loc);

            String[] tokens = StringUtils.split(loc.name, " ");

            if (tokens.length == 1) {
                geonames = queries.doSelectQuery(queryString);
            } else if (tokens.length > 1) {
                geonames = queries.doNameQuery(queryString);
            }//  w w  w  .  j a  v a 2  s  . c o m

            if (geonames.size() == 0 && loc.hints != null) {
                loc.hints = null;
                queryString = getQueryString(loc);
                if (tokens.length == 1) {
                    geonames = queries.doSelectQuery(queryString);
                } else if (tokens.length > 1) {
                    geonames = queries.doNameQuery(queryString);
                }
            }
            if (geonames.size() > 0) {
                loc.geoNamesEntries.addAll(geonames);
            }
        } else if (loc.detectedBy.equals("RGX")) {
            double lat = loc.geocoordMatch.getLatitude();
            double lon = loc.geocoordMatch.getLongitude();
            String lonLat = lon + " " + lat;
            List<BorderData> results = queries.doBorderQuery(lonLat);

            GeoNamesEntry entry = new GeoNamesEntry();
            for (BorderData bd : results) {
                if (StringUtils.equals(bd.shapeType, "adm0")) {
                    entry.countryCode = bd.iso2;
                } else if (StringUtils.equals(bd.shapeType, "adm1")) {
                    entry.admin1 = bd.name;
                } else if (StringUtils.equals(bd.shapeType, "adm2")) {
                    entry.admin2 = bd.name;
                }
            }
            entry.name = loc.name;
            entry.score = 1.0f;
            entry.setLevenshteinScore(1.0f);
            loc.geoNamesEntries.add(entry);
        }
    }
    return locs;
}

From source file:cn.cuizuoli.gotour.controller.WebListController.java

@RequestMapping("list")
@ResponseBody//from w  w  w .java  2s  .  c  o m
public DataResult list(@RequestBody SearchCondition searchCondition) {
    searchCondition.setPageSize(100);
    DataResult dataResult = new DataResult();
    if (StringUtils.equals(searchCondition.getProductCode(), ProductType.LOCAL.getCode())) {
        dataResult = localService.getLocalList(searchCondition);
    }
    if (StringUtils.equals(searchCondition.getProductCode(), ProductType.INTERNAL.getCode())) {
        dataResult = internalService.getInternalList(searchCondition);
    }
    if (StringUtils.equals(searchCondition.getProductCode(), ProductType.OUTDOOR.getCode())) {
        dataResult = outdoorService.getOutdoorList(searchCondition);
    }
    if (StringUtils.equals(searchCondition.getProductCode(), ProductType.ATTRACTIONS.getCode())) {
        dataResult = attractionsService.getAttractionsList(searchCondition);
    }
    if (StringUtils.equals(searchCondition.getProductCode(), ProductType.EXPANSION_TRAINING.getCode())) {
        dataResult = trainingService.getTrainingList(searchCondition);
    }
    return dataResult;
}

From source file:net.librec.filter.GenericRecommendedFilter.java

/**
 * filter the recommended list by specified type of the filter.
 *
 * @param filterIdList          filter id list
 * @param recommendedList       recommended item list
 * @param filterRecommendedSet  filter recommended set
 * @param filterType            type of the filter
 *///from www. j a  v a2  s  . c om
private void filter(List<String> filterIdList, List<RecommendedItem> recommendedList,
        Set<RecommendedItem> filterRecommendedSet, String filterType) {
    if (filterIdList != null && filterIdList.size() > 0) {
        for (String filterId : filterIdList) {
            for (RecommendedItem recommendedItem : recommendedList) {
                String recommendedId = null;
                if (StringUtils.equals("user", filterType)) {
                    recommendedId = recommendedItem.getUserId();
                } else if (StringUtils.equals("item", filterType)) {
                    recommendedId = recommendedItem.getItemId();
                }
                if (StringUtils.equals(filterId, recommendedId)) {
                    filterRecommendedSet.add(recommendedItem);
                }
            }
        }
    }
}

From source file:com.skymobi.monitor.action.UserAction.java

@RequestMapping(value = "/check")
public String check(User user, ModelMap map, HttpServletRequest request) throws UnsupportedEncodingException {
    logger.debug("try to login by {} ", user);
    User _user = userManager.loadUserByUsername(user.getUsername());
    if (_user == null) {
        map.put("flashMsg", "user or password error");
        return "user/login";
    }/*from   w ww  .ja  va 2s.  com*/
    if (!StringUtils.equals(user.getPassword(), _user.getPassword())) {
        map.put("flashMsg", "err.password_err");
        return "user/login";
    }
    if (!_user.isEnabled()) {
        return "redirect:/user/wait?username=" + URLEncoder.encode(user.getUsername(), "utf-8");
    }
    return "redirect:/projects";
}

From source file:net.shopxx.plugin.qqLogin.QqLoginPlugin.java

@Override
public boolean verifyNotify(HttpServletRequest request) {
    String state = (String) request.getSession().getAttribute(STATE_ATTRIBUTE_NAME);
    if (StringUtils.isNotEmpty(state) && StringUtils.equals(state, request.getParameter("state"))
            && StringUtils.isNotEmpty(request.getParameter("code"))) {
        request.getSession().removeAttribute(STATE_ATTRIBUTE_NAME);
        PluginConfig pluginConfig = getPluginConfig();
        Map<String, Object> parameterMap = new HashMap<String, Object>();
        parameterMap.put("grant_type", "authorization_code");
        parameterMap.put("client_id", pluginConfig.getAttribute("oauthKey"));
        parameterMap.put("client_secret", pluginConfig.getAttribute("oauthSecret"));
        parameterMap.put("redirect_uri", getNotifyUrl());
        parameterMap.put("code", request.getParameter("code"));
        String content = WebUtils.get("https://graph.qq.com/oauth2.0/token", parameterMap);
        String accessToken = WebUtils.parse(content).get("access_token");
        if (StringUtils.isNotEmpty(accessToken)) {
            request.setAttribute("accessToken", accessToken);
            return true;
        }/*  w w  w.  j  a  v a2  s.  c o  m*/
    }
    return false;
}

From source file:jp.primecloud.auto.service.impl.VmwareDescribeServiceImpl.java

/**
 * {@inheritDoc}/*from w  w  w . j av a  2s  .  c om*/
 */
@Override
public List<ComputeResource> getComputeResources(Long platformNo) {
    PlatformVmware platformVmware = platformVmwareDao.read(platformNo);

    VmwareClientFactory factory = new VmwareClientFactory();
    factory.setUrl(platformVmware.getUrl());
    factory.setUsername(platformVmware.getUsername());
    factory.setPassword(platformVmware.getPassword());
    factory.setDatacenterName(platformVmware.getDatacenter());

    factory.setIgnoreCert(true);
    VmwareClient vmwareClient = factory.createVmwareClient();

    List<ComputeResource> computeResources = new ArrayList<ComputeResource>();

    ManagedEntity[] entities = vmwareClient.searchByType(ComputeResource.class);
    for (ManagedEntity entity : entities) {
        ComputeResource computeResource = ComputeResource.class.cast(entity);
        if (StringUtils.isNotEmpty(platformVmware.getComputeResource())
                && !StringUtils.equals(computeResource.getName(), platformVmware.getComputeResource())) {
            continue;
        }
        computeResources.add(computeResource);
    }

    // 
    Collections.sort(computeResources, Comparators.COMPARATOR_COMPUTE_RESOURCE);

    return computeResources;
}

From source file:com.adobe.acs.samples.predicates.impl.SamplePredicate.java

@Override
public final boolean evaluate(final Object object) {
    if (object instanceof SyntheticResource) {
        // If the object is a Synthetic Resource
        final Resource resource = (Resource) object;
        final ValueMap properties = resource.getValueMap();

        // Check the Synthetic Resource as needed to figure out if it should be filtered in or out.
        return StringUtils.equals(properties.get("cat", String.class), "meow");
    } else {/* w  w w .java  2s.  c  om*/
        // If not a SyntheticResource then use AbstractNodePredicate's "default" evaluation rules, which will
        // in turn call this.evaluate(Node node) defined below if the object is a/adaptable to a JCR Node.
        return super.evaluate(object);
    }
}