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

net.sf.jsimpletools.utils.SequenceValidator Maven / Gradle / Ivy

There is a newer version: 0.3.1
Show newest version
/*
 * #%L
 * jSimpleTools
 * %%
 * Copyright (C) 2011 - 2015 Eric-Karl Matteau 
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */
package net.sf.jsimpletools.utils;

import net.sf.jsimpletools.Errors;

class SequenceValidator {

    public static void validateLong(long value, long step) {
        if (value > Long.MAX_VALUE - step) {
            throw Errors.SEQUENCE_MAX_VALUE_REACHED.exception("long");
        }
    }

    public static void validateInteger(long value) {
        if (value >= Integer.MAX_VALUE) {
            throw Errors.SEQUENCE_MAX_VALUE_REACHED.exception("integer");
        }
    }

    public static void validateShort(long value) {
        if (value >= Short.MAX_VALUE) {
            throw Errors.SEQUENCE_MAX_VALUE_REACHED.exception("short");
        }
    }

    public static void validateByte(long value) {
        if (value >= Byte.MAX_VALUE) {
            throw Errors.SEQUENCE_MAX_VALUE_REACHED.exception("byte");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy