com.jpattern.orm.generator.ValidValueChecker Maven / Gradle / Ivy
package com.jpattern.orm.generator;
import java.math.BigDecimal;
/**
*
* @author Francesco Cina'
*
* Apr 1, 2012
*/
public abstract class ValidValueChecker {
public static final String METHOD_NAME = "useGenerator";
public static boolean useGenerator(long[] validValues, byte value) {
return contains(validValues, value);
}
public static boolean useGenerator(long[] validValues, short value) {
return contains(validValues, value);
}
public static boolean useGenerator(long[] validValues, int value) {
return contains(validValues, value);
}
public static boolean useGenerator(long[] validValues, long value) {
return contains(validValues, value);
}
// public boolean increase(long[] validValues, float value) {
// return false;
// }
//
// public boolean increase(long[] validValues, double value) {
// return false;
// }
public static boolean useGenerator(long[] validValues, BigDecimal value) {
if (value==null) {
return true;
}
return contains(validValues, value.longValue());
}
private static boolean contains(long[] validValues, long value) {
if (validValues.length==0) {
return true;
}
for (final long validValue : validValues) {
if (validValue == value) {
return true;
}
}
return false;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy