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