net.sf.jsimpletools.utils.SequenceValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsimpletools-core Show documentation
Show all versions of jsimpletools-core Show documentation
A simple tool box to assist in coding tests in Java. Core module.
/*
* #%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");
}
}
}