All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.ipokerface.common.utils.NumberUtils Maven / Gradle / Ivy

There is a newer version: 2.9.1
Show newest version
package cn.ipokerface.common.utils;


/**
 * Created by       PokerFace
 * Create Date      2019-10-28.
 * Email:
 * Version          1.0.0
 *
 * Description:
 */
public class NumberUtils {


    /**
     *  ture if number is not null and is not zero
     *
     * @param number value
     * @return value is not null
     */
    public static boolean notZero(Number number){


        return number != null && number.intValue() != 0;
    }


    /**
     *  true if number is null or zero
     *
     * @param number value
     * @return value is null
     */
    public static boolean isZero(Number number) {
        return !notZero(number);
    }


    /**
     *  transfer null to zero if number is null or is zero
     *
     * @param number value
     * @return value or 0
     */
    public static int zeroIfNull(Integer number){
        return number == null? 0: number;
    }


    /**
     *  transfer null to zero if number is null or is zero
     *
     * @param number value
     * @return value or 0
     */
    public static long zeroIfNull(Long number){
        return number == null? 0: number;
    }




}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy