@Test public void testGetArgAsLongFromBoolean2() { assertEquals("getArgAsLong() failed!", 0L, FunctionUtil.getArgAsLong(Boolean.valueOf(false))); }
public static long getArgAsLong(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) return EquationUtil.doubleToLong((Double)arg); if (arg.getClass() == Long.class) return (Long)arg; if (arg.getClass() == String.class) { try { return Long.parseLong((String)arg); } catch (final Exception e) { throw new IllegalArgumentException("can't convert \"" + arg + "\" to a whole number."); } } if (arg.getClass() == Boolean.class) return (Boolean)arg ? 1L : 0L; throw new IllegalArgumentException("can't convert argument to a whole number."); }
FunctionUtil { public static long getArgAsLong(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) return EquationUtil.doubleToLong((Double)arg); if (arg.getClass() == Long.class) return (Long)arg; if (arg.getClass() == String.class) { try { return Long.parseLong((String)arg); } catch (final Exception e) { throw new IllegalArgumentException("can't convert \"" + arg + "\" to a whole number."); } } if (arg.getClass() == Boolean.class) return (Boolean)arg ? 1L : 0L; throw new IllegalArgumentException("can't convert argument to a whole number."); } }
FunctionUtil { public static long getArgAsLong(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) return EquationUtil.doubleToLong((Double)arg); if (arg.getClass() == Long.class) return (Long)arg; if (arg.getClass() == String.class) { try { return Long.parseLong((String)arg); } catch (final Exception e) { throw new IllegalArgumentException("can't convert \"" + arg + "\" to a whole number."); } } if (arg.getClass() == Boolean.class) return (Boolean)arg ? 1L : 0L; throw new IllegalArgumentException("can't convert argument to a whole number."); } private  FunctionUtil(); }
FunctionUtil { public static long getArgAsLong(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) return EquationUtil.doubleToLong((Double)arg); if (arg.getClass() == Long.class) return (Long)arg; if (arg.getClass() == String.class) { try { return Long.parseLong((String)arg); } catch (final Exception e) { throw new IllegalArgumentException("can't convert \"" + arg + "\" to a whole number."); } } if (arg.getClass() == Boolean.class) return (Boolean)arg ? 1L : 0L; throw new IllegalArgumentException("can't convert argument to a whole number."); } private  FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }
FunctionUtil { public static long getArgAsLong(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) return EquationUtil.doubleToLong((Double)arg); if (arg.getClass() == Long.class) return (Long)arg; if (arg.getClass() == String.class) { try { return Long.parseLong((String)arg); } catch (final Exception e) { throw new IllegalArgumentException("can't convert \"" + arg + "\" to a whole number."); } } if (arg.getClass() == Boolean.class) return (Boolean)arg ? 1L : 0L; throw new IllegalArgumentException("can't convert argument to a whole number."); } private  FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input);  }