@Test public void testCastToBoolean() { Assert.assertTrue(SqlQueryUtils.castToBoolean("y")); Assert.assertTrue(SqlQueryUtils.castToBoolean("yes")); Assert.assertTrue(SqlQueryUtils.castToBoolean("t")); Assert.assertTrue(SqlQueryUtils.castToBoolean("true")); Assert.assertTrue(SqlQueryUtils.castToBoolean("1")); Assert.assertFalse(SqlQueryUtils.castToBoolean("n")); Assert.assertFalse(SqlQueryUtils.castToBoolean("no")); Assert.assertFalse(SqlQueryUtils.castToBoolean("f")); Assert.assertFalse(SqlQueryUtils.castToBoolean("false")); Assert.assertFalse(SqlQueryUtils.castToBoolean("0")); Assert.assertTrue(SqlQueryUtils.castToBoolean("YeS")); Assert.assertFalse(SqlQueryUtils.castToBoolean("")); Assert.assertFalse(SqlQueryUtils.castToBoolean("asdfafgsagareg")); }
public static boolean castToBoolean(String fieldValue) { String lowerField = fieldValue.toLowerCase(); switch(lowerField) { case "y": return true; case "n": return false; case "true": return true; case "false": return false; case "t": return true; case "f": return false; case "yes": return true; case "no": return false; case "0": return false; case "1": return true; } return false; }
SqlQueryUtils { public static boolean castToBoolean(String fieldValue) { String lowerField = fieldValue.toLowerCase(); switch(lowerField) { case "y": return true; case "n": return false; case "true": return true; case "false": return false; case "t": return true; case "f": return false; case "yes": return true; case "no": return false; case "0": return false; case "1": return true; } return false; } }
SqlQueryUtils { public static boolean castToBoolean(String fieldValue) { String lowerField = fieldValue.toLowerCase(); switch(lowerField) { case "y": return true; case "n": return false; case "true": return true; case "false": return false; case "t": return true; case "f": return false; case "yes": return true; case "no": return false; case "0": return false; case "1": return true; } return false; }  }
SqlQueryUtils { public static boolean castToBoolean(String fieldValue) { String lowerField = fieldValue.toLowerCase(); switch(lowerField) { case "y": return true; case "n": return false; case "true": return true; case "false": return false; case "t": return true; case "f": return false; case "yes": return true; case "no": return false; case "0": return false; case "1": return true; } return false; }  static String addPredicate(String query, String predicateCond); static boolean castToBoolean(String fieldValue); }
SqlQueryUtils { public static boolean castToBoolean(String fieldValue) { String lowerField = fieldValue.toLowerCase(); switch(lowerField) { case "y": return true; case "n": return false; case "true": return true; case "false": return false; case "t": return true; case "f": return false; case "yes": return true; case "no": return false; case "0": return false; case "1": return true; } return false; }  static String addPredicate(String query, String predicateCond); static boolean castToBoolean(String fieldValue);  }