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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:com.cognifide.qa.bb.expectedconditions.UrlExpectedConditions.java

/**
 * Check if provided url and current url are the same
 *
 * @param url Url pattern/*  w w w  .  jav  a 2 s.  c  o m*/
 * @return false if current url is different than provided url or WebDriver is null
 */
public static ExpectedCondition<Boolean> pageUrlIs(final String url) {
    return driver -> StringUtils.equals(driver.getCurrentUrl(), url);
}

From source file:keepinchecker.network.PacketParser.java

public static String parse(String keyword, String packet) {
    String value = "";

    if (!StringUtils.contains(packet, keyword)) {
        return value;
    }/*  w  w  w. j  ava2s  .co m*/

    String[] packetSplitOnNewline = packet.split("\n");
    for (String line : packetSplitOnNewline) {
        if (StringUtils.equals(keyword, GET) && StringUtils.contains(line, keyword)) {
            value = StringUtils.substringBefore(line.split(keyword)[1], "HTTP");
            break;
        } else if ((StringUtils.contains(line, HOST) || StringUtils.contains(line, REFERER))
                && StringUtils.contains(line, keyword)) {
            value = line.split(keyword + ":")[1];
            break;
        }
    }

    return value.trim();
}

From source file:com.baifendian.swordfish.execserver.job.impexp.ImpExpJobManager.java

public static Job newJob(String jobTypeStr, JobProps props, Logger logger) throws IllegalArgumentException {
    if (!StringUtils.equals(jobTypeStr, IMPEXP)) {
        logger.error("unsupport job type: {}", jobTypeStr);
        throw new IllegalArgumentException("Not support job type");
    }//  w  w w.  j a v a 2s  .  com

    ImpExpParam impExpParam = (ImpExpParam) BaseParamFactory.getBaseParam(jobTypeStr, props.getJobParams());
    ImpExpProps impExpProps = new ImpExpProps(impExpParam, logger);

    switch (impExpParam.getType()) {
    case MYSQL_TO_HIVE:
        return new MysqlToHiveJob(props, false, logger, impExpProps);
    case MYSQL_TO_HDFS:
        return new MysqlToHdfsJob(props, false, logger, impExpProps);
    case HIVE_TO_MYSQL:
        return new HiveToMysqlJob(props, false, logger, impExpProps);
    case HIVE_TO_MONGODB:
        return new HiveToMongoJob(props, false, logger, impExpProps);
    case FILE_TO_HIVE:
        return new FileToHiveJob(props, false, logger, impExpProps);
    case POSTGRES_TO_HIVE:
        return new PostgreToHiveJob(props, false, logger, impExpProps);
    case HIVE_TO_POSTGRES:
        return new HiveToPostgreJob(props, false, logger, impExpProps);
    case POSTGRES_TO_HDFS:
        return new PostgreToHdfsJob(props, false, logger, impExpProps);
    default:
        logger.error("unsupport ImpExp job type: {}", jobTypeStr);
        throw new IllegalArgumentException("Not support job type");
    }
}

From source file:com.widowcrawler.core.util.DomainUtils.java

public static boolean isBaseDomain(String baseDomain, String url) {
    try {//from  w  ww  .  j a  v a2s .c o m
        baseDomain = StringUtils.lowerCase(StringUtils.trim(baseDomain));
        String domain = StringUtils.lowerCase(StringUtils.trimToNull(new URI(url).getHost()));

        if (domain == null) {
            logger.info("Returning false because url's domain is null");
            return false;
        }

        while (StringUtils.isNotBlank(domain)) {
            if (StringUtils.equals(baseDomain, domain)) {
                return true;
            }

            domain = StringUtils.substringAfter(domain, ".");
        }

        return false;

    } catch (URISyntaxException ex) {
        logger.error("Could not determine base domain relationship. Returning default of false.", ex);
        return false;
    }
}

From source file:com.thruzero.common.core.support.utils.PairTestUtils.java

public static void testExpectedResult(String result) {
    String expectedResult = "This is a test.\nThis is a test too.\nHere's a substitution var: "
            + SubstitutionVisitorTest.SUBSTITUTION_VALUE_1 + "\nThis is another test.\n";

    assertTrue("Substitution failed - does not match expected result.",
            StringUtils.equals(result, expectedResult));
}

From source file:jease.cms.service.Timers.java

public static void start() {
    stop();/*from  w  ww  .  j  a v  a 2 s  .  c om*/
    timer = new Timer();
    timer.schedule(new TimerTask() {
        public void run() {
            try {
                String newTimerTaskClass = Registry.getParameter(Names.JEASE_TIMER_TASK);
                if (StringUtils.isNotBlank(newTimerTaskClass)) {
                    if (!StringUtils.equals(timerTaskClass, newTimerTaskClass)) {
                        timerTaskClass = newTimerTaskClass;
                        runnable = (Runnable) Reflections.newInstance(timerTaskClass);
                    }
                    if (runnable != null) {
                        runnable.run();
                    }
                }
            } catch (Throwable e) {
                timerTaskClass = null;
                runnable = null;
            }
        }
    }, 1000, 1000);
}

From source file:io.wcm.caravan.pipeline.extensions.hal.filter.HalResourceMatchers.java

/**
 * @param relationToMatch HAL resource relation
 * @return True if resource has given relation
 *//* w w w .j  a  va  2 s . com*/
public static HalResourcePredicate relation(String relationToMatch) {
    return new HalResourcePredicate() {

        @Override
        public String getId() {
            return "MATCHES(/" + relationToMatch + ")";
        }

        @Override
        public boolean apply(HalPath halPath, HalResource hal) {
            return StringUtils.equals(relationToMatch, halPath.current());
        }

    };
}

From source file:io.relution.jenkins.awssqs.util.ErrorType.java

/**
 * Returns a value indicating whether the specified service exception has the specified error
 * code and HTTP status./* ww w.  j a v a  2 s.c  o m*/
 * @param e The {@link AmazonServiceException} to test.
 * @param errorCode The error code to match, can be {@code null}.
 * @param httpStatus The HTTP status to match. Use {@code -1} to match any HTTP status.
 * @return {@code true} if the specified exception has the specified error code and HTTP status;
 * otherwise, {@code false}.
 */
public static boolean is(final AmazonServiceException e, final String errorCode, final int httpStatus) {
    if (e == null) {
        return false;
    }

    if (errorCode != null && !StringUtils.equals(errorCode, e.getErrorCode())) {
        return false;
    }

    if (httpStatus != -1 && e.getStatusCode() != httpStatus) {
        return false;
    }

    return true;
}

From source file:gob.dp.simco.registro.type.TipologiaCasoType.java

public static String tipoClasificacionNombre(String codigo) {
    if (StringUtils.equals(codigo, AGL.key))
        return AGL.value;
    if (StringUtils.equals(codigo, AGN.key))
        return AGN.value;
    if (StringUtils.equals(codigo, AGR.key))
        return AGR.value;
    if (StringUtils.equals(codigo, COM.key))
        return COM.value;
    if (StringUtils.equals(codigo, CIC.key))
        return CIC.value;
    if (StringUtils.equals(codigo, DEM.key))
        return DEM.value;
    if (StringUtils.equals(codigo, ELE.key))
        return ELE.value;
    if (StringUtils.equals(codigo, LAB.key))
        return LAB.value;
    if (StringUtils.equals(codigo, SOC.key))
        return SOC.value;
    if (StringUtils.equals(codigo, OTR.key))
        return OTR.value;
    return "";
}

From source file:com.nagopy.android.xposed.util.XUtil.java

/**
 * UI????./* www.j a  v a 2  s . co  m*/
 * 
 * @param packageName ??
 * @return UI?true????false?
 */
public static Boolean isSystemUi(String packageName) {
    return StringUtils.equals(packageName, XConst.PKG_SYSTEM_UI);
}