/** * Construct a StringProperty from a literal value and with the given alias, e.g. "'hello' AS greeting" * * @param literal the literal value * @param selectAs the alias to use. May be null. */ public static StringProperty literal(String literal, String selectAs) { return new StringProperty(null, SqlUtils.sanitizeStringAsLiteral(literal), selectAs, null); }
/** * Construct a StringProperty from a {@link Function} and with the given alias, e.g. * "UPPER(column) AS uppercase" * * @param function the function * @param selectAs the alias to use. May be null. */ public static StringProperty fromFunction(Function<String> function, String selectAs) { return new StringProperty(function, selectAs); }
public void testEqualsAndHashCode() { LongProperty test1 = new LongProperty( new TableModelName(TestModel.class, TestModel.TABLE.getName()), "testCol"); LongProperty test2 = new LongProperty( new TableModelName(TestModel.class, TestModel.TABLE.getName()), "testCol"); assertEquals(test1, test2); assertEquals(test1.hashCode(), test2.hashCode()); StringProperty test3 = new StringProperty( new TableModelName(TestModel.class, TestModel.TABLE.getName()), "testCol"); StringProperty test4 = new StringProperty( new TableModelName(TestModel.class, TestModel.TABLE.getName()), "testCol", "DEFAULT 'A'"); assertEquals(test3, test4); assertEquals(test3.hashCode(), test4.hashCode()); Function<Integer> func1 = Function.count(); Function<Integer> func2 = Function.rawFunction("COUNT(*)"); assertEquals(func1, func2); assertEquals(func1.hashCode(), func2.hashCode()); IntegerProperty test5 = Property.IntegerProperty.fromFunction(func1, "count"); IntegerProperty test6 = Property.IntegerProperty.fromFunction(func2, "count"); assertEquals(test5, test6); assertEquals(test5.hashCode(), test6.hashCode()); }
public void testTryAddColumn() { StringProperty goodProperty = new StringProperty( new TableModelName(TestModel.class, TestModel.TABLE.getName()), "good_column"); testHookDatabase.tryAddColumn(goodProperty); // don't care about the result, just that it didn't throw final StringProperty badProperty = new StringProperty( new TableModelName(TestViewModel.class, TestViewModel.VIEW.getName()), "bad_column"); testThrowsException(new Runnable() { @Override public void run() { testHookDatabase.tryAddColumn(badProperty); } }, IllegalArgumentException.class); }
/** * Construct a StringProperty from a literal value and with the given alias, e.g. "'hello' AS greeting" * * @param literal the literal value * @param selectAs the alias to use. May be null. */ public static StringProperty literal(String literal, String selectAs) { return new StringProperty(null, SqlUtils.sanitizeStringAsLiteral(literal), selectAs, null); }
/** * Construct a StringProperty from a {@link Function} and with the given alias, e.g. * "UPPER(column) AS uppercase" * * @param function the function * @param selectAs the alias to use. May be null. */ public static StringProperty fromFunction(Function<String> function, String selectAs) { return new StringProperty(function, selectAs); }