/** * Returns whether <code>ordinal</code> is valid for this enumeration. * This method is particularly useful in pre- and post-conditions, for * example * <blockquote> * <pre>@param axisCode Axis code, must be a {@link AxisCode} value * @pre AxisCode.instance.isValid(axisCode)</pre> * </blockquote> * * @param ordinal Suspected ordinal from this enumeration. * @return Whether <code>ordinal</code> is valid. */ public final boolean isValid(int ordinal) { if ((ordinal < min) || (ordinal > max)) { return false; } if (getName(ordinal) == null) { return false; } return true; }
/** * Returns an error indicating that the value is illegal. (The client needs * to throw the error.) */ public RuntimeException badValue(int ordinal) { return Util.newInternal( "bad value " + ordinal + "(" + getName(ordinal) + ") for enumeration '" + getClass().getName() + "'"); }