@Test public void testGetArgAsBooleanWithZeroLong() { assertEquals("getArgAsBoolean() failed!", false, FunctionUtil.getArgAsBoolean(0L)); }
public static boolean getArgAsBoolean(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) { final double d = (Double)arg; return d == 0.0 ? false : true; } if (arg.getClass() == Long.class) { final long l = (Long)arg; return l == 0L ? false : true; } if (arg.getClass() == String.class) { final String argAsString = (String)arg; if (argAsString.equalsIgnoreCase(Boolean.TRUE.toString())) return true; if (argAsString.equalsIgnoreCase(Boolean.FALSE.toString())) return false; throw new IllegalArgumentException("can't convert \"" + argAsString + "\" to a boolean."); } if (arg.getClass() == Boolean.class) return (Boolean)arg; throw new IllegalArgumentException("can't convert argument to a boolean."); }
FunctionUtil { public static boolean getArgAsBoolean(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) { final double d = (Double)arg; return d == 0.0 ? false : true; } if (arg.getClass() == Long.class) { final long l = (Long)arg; return l == 0L ? false : true; } if (arg.getClass() == String.class) { final String argAsString = (String)arg; if (argAsString.equalsIgnoreCase(Boolean.TRUE.toString())) return true; if (argAsString.equalsIgnoreCase(Boolean.FALSE.toString())) return false; throw new IllegalArgumentException("can't convert \"" + argAsString + "\" to a boolean."); } if (arg.getClass() == Boolean.class) return (Boolean)arg; throw new IllegalArgumentException("can't convert argument to a boolean."); } }
FunctionUtil { public static boolean getArgAsBoolean(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) { final double d = (Double)arg; return d == 0.0 ? false : true; } if (arg.getClass() == Long.class) { final long l = (Long)arg; return l == 0L ? false : true; } if (arg.getClass() == String.class) { final String argAsString = (String)arg; if (argAsString.equalsIgnoreCase(Boolean.TRUE.toString())) return true; if (argAsString.equalsIgnoreCase(Boolean.FALSE.toString())) return false; throw new IllegalArgumentException("can't convert \"" + argAsString + "\" to a boolean."); } if (arg.getClass() == Boolean.class) return (Boolean)arg; throw new IllegalArgumentException("can't convert argument to a boolean."); } private  FunctionUtil(); }
FunctionUtil { public static boolean getArgAsBoolean(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) { final double d = (Double)arg; return d == 0.0 ? false : true; } if (arg.getClass() == Long.class) { final long l = (Long)arg; return l == 0L ? false : true; } if (arg.getClass() == String.class) { final String argAsString = (String)arg; if (argAsString.equalsIgnoreCase(Boolean.TRUE.toString())) return true; if (argAsString.equalsIgnoreCase(Boolean.FALSE.toString())) return false; throw new IllegalArgumentException("can't convert \"" + argAsString + "\" to a boolean."); } if (arg.getClass() == Boolean.class) return (Boolean)arg; throw new IllegalArgumentException("can't convert argument to a boolean."); } 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 boolean getArgAsBoolean(final Object arg) throws IllegalArgumentException { if (arg.getClass() == Double.class) { final double d = (Double)arg; return d == 0.0 ? false : true; } if (arg.getClass() == Long.class) { final long l = (Long)arg; return l == 0L ? false : true; } if (arg.getClass() == String.class) { final String argAsString = (String)arg; if (argAsString.equalsIgnoreCase(Boolean.TRUE.toString())) return true; if (argAsString.equalsIgnoreCase(Boolean.FALSE.toString())) return false; throw new IllegalArgumentException("can't convert \"" + argAsString + "\" to a boolean."); } if (arg.getClass() == Boolean.class) return (Boolean)arg; throw new IllegalArgumentException("can't convert argument to a boolean."); } 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);  }