/** * Create an ENUM value from the provided enumerators * and value. * * @param enumerators the enumerators * @param value a value * @return the ENUM value */ public static ValueEnum get(final String[] enumerators, int value) { check(enumerators, ValueInt.get(value)); return new ValueEnum(enumerators, value); }
public static ValueEnum get(final String[] enumerators, String value) { check(enumerators, ValueString.get(value)); final String cleanLabel = sanitize(value); for (int i = 0; i < enumerators.length; i++) { if (cleanLabel.equals(sanitize(enumerators[i]))) { return new ValueEnum(enumerators, i); } } throw DbException.get(ErrorCode.GENERAL_ERROR_1, "Unexpected error"); }
private static void check(final String[] enumerators, final Value value) { check(enumerators); if (validate(enumerators, value) != Validation.VALID) { throw DbException.get(ErrorCode.ENUM_VALUE_NOT_PERMITTED, toString(enumerators), value.toString()); } }
ValueEnum.check(enumerators); } catch (DbException e) { throw e.addSQL(original);