/** * Create a new instance using the given flag * <p>The used position is before the target.</p> * * @param flag flag in String form */ public JoinFlag(String flag) { this(ExpressionUtils.template(Object.class, flag), Position.BEFORE_TARGET); }
protected EnumTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected DateTimeTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
/** * Create a new instance using the given flag and position. * * @param flag flag in String form * @param position position of the flag in the join */ public JoinFlag(String flag, Position position) { this(ExpressionUtils.template(Object.class, flag), position); }
protected NumberTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected DslTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected TimeTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected DateTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected ComparableTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
protected StringTemplate(Template template, ImmutableList<?> args) { super(ExpressionUtils.template(String.class, template, args)); this.templateMixin = (TemplateExpressionImpl<String>) mixin; }
protected SimpleTemplate(Class<? extends T> type, Template template, ImmutableList<?> args) { super(ExpressionUtils.template(type, template, args)); templateMixin = (TemplateExpressionImpl<T>) mixin; }
public QueryFlag(Position position, String flag) { this(position, ExpressionUtils.template(Object.class, flag)); }
/** * Create a new Template expression * * @param cl type of expression * @param template template * @param args template parameters * @return template expression */ public static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, Object... args) { return template(cl, template, ImmutableList.copyOf(args)); }
/** * Create a new Template expression * * @param cl type of expression * @param template template * @param args template parameters * @return template expression */ public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, Object... args) { return template(cl, TemplateFactory.DEFAULT.create(template), ImmutableList.copyOf(args)); }
/** * Create a new Template expression * * @param cl type of expression * @param template template * @param args template parameters * @return template expression */ public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args) { return template(cl, TemplateFactory.DEFAULT.create(template), args); }
/** * Create a new Template expression * * @deprecated Use {@link #template(Class, String, List)} instead. * * @param cl type of expression * @param template template * @param args template parameters * @return template expression */ @Deprecated public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, ImmutableList<?> args) { return template(cl, TemplateFactory.DEFAULT.create(template), args); }
@Test public void template() { Expression<Boolean> template = ExpressionUtils.template(Boolean.class, "{0} is not null", QCat.cat.name); assertEquals("cat_name is not null", template.accept(ToStringVisitor.DEFAULT, templates)); }
@Test public void template() { Expression<Boolean> templateExpr = ExpressionUtils.template(Boolean.class, "{0} = {1}", cat.kittens.any().name, ConstantImpl.create("Ruth123")); assertEquals("cat_kittens_0.name = Ruth123", serialize(templateExpr)); }
@Test public void test() { DummySerializer serializer = new DummySerializer(new JavaTemplates()); StringPath strPath = Expressions.stringPath("str"); // path serializer.handle(strPath); // operation serializer.handle(strPath.isNotNull()); // long path serializer.handle(new PathBuilder<Object>(Object.class,"p").getList("l",Map.class).get(0)); // constant serializer.handle(ConstantImpl.create("")); // custom serializer.handle(ExpressionUtils.template(Object.class, "xxx", ConstantImpl.create(""))); }