@Test public void testConvertToBoolean() { final Object[][] testParameters = new Object[][] {{"no", false}, {"n", false}, {"false", false}, {"0", false}, {"No", false}, {"False", false}, {"yes", true}, {"y", true}, {"true", true}, {"1", true}, {"Yes", true}, {"True", true}}; for (final Object[] testParameter : testParameters) { boolean expected = (Boolean) testParameter[1]; String val = (String) testParameter[0]; assertEquals(expected, ParsingUtils.convertToBoolean(val)); } }
public static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue) { if (null == str) { return defaultValueIsTrue; } final String safeStr = trim(str).toLowerCase(); if (defaultValueIsTrue) { return !FALSES.contains(safeStr); } else { return TRUES.contains(safeStr); } }
ParsingUtils { public static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue) { if (null == str) { return defaultValueIsTrue; } final String safeStr = trim(str).toLowerCase(); if (defaultValueIsTrue) { return !FALSES.contains(safeStr); } else { return TRUES.contains(safeStr); } } }
ParsingUtils { public static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue) { if (null == str) { return defaultValueIsTrue; } final String safeStr = trim(str).toLowerCase(); if (defaultValueIsTrue) { return !FALSES.contains(safeStr); } else { return TRUES.contains(safeStr); } }  }
ParsingUtils { public static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue) { if (null == str) { return defaultValueIsTrue; } final String safeStr = trim(str).toLowerCase(); if (defaultValueIsTrue) { return !FALSES.contains(safeStr); } else { return TRUES.contains(safeStr); } }  static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue); static boolean convertToBoolean(final String val); static int convertToInt(final String val); static int convertToInt(final String val, final int defaultValue); static long convertToLong(final String val); static long convertToLong(final String val, final int defaultValue); static long convertToLong(final String val, final long defaultValue); static double convertToDouble(final String val); static double convertToDouble(final String val, final double defaultValue); static long convertToCapacity(
      final String str,
      final long defaultValue); static long convertToTime(final String val); static long parse(
      final String val,
      final TimeUnit unit); }
ParsingUtils { public static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue) { if (null == str) { return defaultValueIsTrue; } final String safeStr = trim(str).toLowerCase(); if (defaultValueIsTrue) { return !FALSES.contains(safeStr); } else { return TRUES.contains(safeStr); } }  static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue); static boolean convertToBoolean(final String val); static int convertToInt(final String val); static int convertToInt(final String val, final int defaultValue); static long convertToLong(final String val); static long convertToLong(final String val, final int defaultValue); static long convertToLong(final String val, final long defaultValue); static double convertToDouble(final String val); static double convertToDouble(final String val, final double defaultValue); static long convertToCapacity(
      final String str,
      final long defaultValue); static long convertToTime(final String val); static long parse(
      final String val,
      final TimeUnit unit); static final List<ScaleUnit> INTERVALS; }