Example usage for org.apache.commons.lang.math NumberUtils LONG_ZERO

List of usage examples for org.apache.commons.lang.math NumberUtils LONG_ZERO

Introduction

In this page you can find the example usage for org.apache.commons.lang.math NumberUtils LONG_ZERO.

Prototype

Long LONG_ZERO

To view the source code for org.apache.commons.lang.math NumberUtils LONG_ZERO.

Click Source Link

Document

Reusable Long constant for zero.

Usage

From source file:com.impetus.kundera.utils.NumericUtils.java

/**
 *  Check if zero//ww  w. j a v a2 s .c o  m
 * @param value        value string
 * @param valueClazz   value class 
 * @return             
 */
public static final boolean checkIfZero(String value, Class valueClazz) {
    boolean returnValue = false;
    if (value != null && NumberUtils.isNumber(value) && numberTypes.get(valueClazz) != null) {
        switch (numberTypes.get(valueClazz)) {

        case INTEGER:
            returnValue = Integer.parseInt(value) == (NumberUtils.INTEGER_ZERO);
            break;

        case FLOAT:
            returnValue = Float.parseFloat(value) == (NumberUtils.FLOAT_ZERO);
            break;

        case LONG:
            returnValue = Long.parseLong(value) == (NumberUtils.LONG_ZERO);
            break;

        case BIGDECIMAL:
            returnValue = new BigDecimal(value) == (BigDecimal.ZERO);
            break;

        case BIGINTEGER:
            returnValue = new BigInteger(value) == (BigInteger.ZERO);
            break;

        case SHORT:
            returnValue = new Short(value) == (NumberUtils.SHORT_ZERO);
            break;
        }
    }

    return returnValue;
}

From source file:edu.utah.further.fqe.impl.service.route.UTestAsynchronousRoute.java

/**
 * A dummy search query that depends on another search query.
 * //from w w  w  . ja  v  a2  s .co m
 * @param dependencyQid
 *            the QID we depend on
 * @param outcomeQid
 *            our QID
 * @return search query instance
 */
private static SearchQuery newDependentSearchQuery(final long dependencyQid, final long outcomeQid) {
    final SearchCriterion searchCriterion = SearchCriteria.junction(CONJUNCTION);
    // Set desired # records to 0 on purpose; if the dependent query is not
    // correctly parsed by SearchQueryDeEvaluator, this will cause a wrong
    // expected # results in the test. If the parser works correctly, it will replace
    // the value of the second criterion by the desired # records, which will then
    // be output by DataSourceMock.
    searchCriterion.addCriterion(simpleExpression(EQ, "numRecords", NumberUtils.LONG_ZERO));
    searchCriterion.addCriterion(simpleExpression(EQ, "id", "QUERY[" + dependencyQid + "].id"));
    final SearchQuery searchQuery = SearchCriteria.query(searchCriterion, "Person");
    searchQuery.setId(new Long(outcomeQid));
    return searchQuery;
}

From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.java

/**
* This method retrieves the memory statistics from the domain given as parameters.
* If no memory statistic is found, it will return {@link NumberUtils#LONG_ZERO} as the value of free memory in the domain.
* If it can retrieve the domain memory statistics, it will return the free memory statistic; that means, it returns the value at the first position of the array returned by {@link Domain#memoryStats(int)}.
*
* @return the amount of free memory in KBs
*///www.ja v a 2s  .c o  m
protected long getMemoryFreeInKBs(Domain dm) throws LibvirtException {
    MemoryStatistic[] mems = dm.memoryStats(NUMMEMSTATS);
    if (ArrayUtils.isEmpty(mems)) {
        return NumberUtils.LONG_ZERO;
    }
    return mems[0].getValue();
}