package net.ranides.assira.math;

import lombok.experimental.UtilityClass;

/**
 * Some utility methods for checking number characterictics
 */
@UtilityClass
public class NumberTraits {

    /**
     * Returns true if value is odd (not multiple of 2)
     *
     * @param value value
     * @return boolean
     */
    public static boolean isOdd(int value) {
        return value % 2 == 1;
    }

    /**
     * Returns true if value is even (multiple of 2)
     *
     * @param value value
     * @return boolean
     */
    public static boolean isEven(int value) {
        return value % 2 == 0;
    }

    public static boolean isZero(Number value) {
        return isInt(value) && value.intValue() == 0;
    }

    public static boolean isOne(Number value) {
        return isInt(value) && value.intValue() == 1;
    }

    public static boolean isInt(Number value) {
        return value.intValue() == value.doubleValue();
    }

}
