TypeInferenceUtils { public static boolean isBoolean(String value) { if (isEmpty(value)) { return false; } if ((value.trim().length() == 4 || value.trim().length() == 5) && ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value))) { return true; } return false; }  static boolean isDouble(String value); static boolean isInteger(String value); static boolean isNumber(String value); static BigInteger getBigInteger(String value); static boolean isBoolean(String value); static boolean isDate(String value); static boolean isTime(String value); static boolean isEmpty(String value); static boolean isValid(DataTypeEnum type, String value); static DataTypeEnum getDataType(String value); static DataTypeEnum getNativeDataType(String value);  }
@Test public void testIsBoolean() throws Exception { List<String> values = loadData("testBoolean.csv"); int countOfBooleans = 0; long timeStart = System.currentTimeMillis(); Assert.assertEquals(10000, values.size()); for (String value : values) { if (TypeInferenceUtils.isBoolean(value)) { countOfBooleans++; } } long timeEnd = System.currentTimeMillis(); Assert.assertEquals(2000, countOfBooleans); long difference = timeEnd - timeStart; LOGGER.debug("The method isBoolean spent " + difference + " ms on 10000 values."); }