/** * Gets the short value of the supplied literal. The fallback value is returned in case * {@link Literal#shortValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the short value for. * @param fallback * The value to fall back to in case no short value could gotten from the literal. * @return Either the literal's short value, or the fallback value. */ public static short getShortValue(Literal l, short fallback) { try { return l.shortValue(); } catch (NumberFormatException e) { return fallback; } }
/** * Gets the short value of the supplied literal. The fallback value is returned in case * {@link Literal#shortValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the short value for. * @param fallback * The value to fall back to in case no short value could gotten from the literal. * @return Either the literal's short value, or the fallback value. */ public static short getShortValue(Literal l, short fallback) { try { return l.shortValue(); } catch (NumberFormatException e) { return fallback; } }