public QSuperSupertype(BeanPath<? extends SuperSupertype> entity) { super(entity.getType(), entity.getMetadata()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public BooleanExpression instanceOfAny(Class... types) { BooleanExpression[] exprs = new BooleanExpression[types.length]; for (int i = 0; i < types.length; i++) { exprs[i] = this.instanceOf(types[i]); } return Expressions.anyOf(exprs); }
/** * Create a new Collection typed path * * @param <A> * @param property property name * @param type property type * @return property path */ @SuppressWarnings("unchecked") protected <A, Q extends SimpleExpression<? super A>> CollectionPath<A, Q> createCollection(String property, Class<? super A> type, Class<? super Q> queryType, PathInits inits) { return add(new CollectionPath<A, Q>(type, (Class) queryType, forProperty(property), inits)); }
@Test public void as_class_with_inits_cached() { beanPath = new BeanPath<BeanPathTest>(BeanPathTest.class, PathMetadataFactory.forVariable("p"), PathInits.DEFAULT); MyBeanPath otherPath = beanPath.as(MyBeanPath.class); // assertEquals(beanPath, otherPath); assertTrue(otherPath == beanPath.as(MyBeanPath.class)); }
@Test public void instanceOfAny() { BooleanExpression pred1 = beanPath.instanceOf(BeanPathTest.class).or(beanPath.instanceOf(SubClass.class)); BooleanExpression pred2 = beanPath.instanceOfAny(BeanPathTest.class, SubClass.class); assertEquals(pred1, pred2); assertEquals("p instanceof class com.querydsl.core.types.dsl.BeanPathTest || " + "p instanceof class com.querydsl.core.types.dsl.BeanPathTest$SubClass", pred2.toString()); }
@SuppressWarnings("unchecked") @Test public void various() { List<Path<?>> paths = new ArrayList<Path<?>>(); paths.add(new ArrayPath(String[].class, "p")); paths.add(new BeanPath(Object.class, "p")); paths.add(new BooleanPath("p")); paths.add(new CollectionPath(String.class, StringPath.class, "p")); paths.add(new ComparablePath(String.class,"p")); paths.add(new DatePath(Date.class,"p")); paths.add(new DateTimePath(Date.class,"p")); paths.add(new EnumPath(ExampleEnum.class,"p")); paths.add(new ListPath(String.class, StringPath.class, "p")); paths.add(new MapPath(String.class, String.class, StringPath.class, "p")); paths.add(new NumberPath(Integer.class,"p")); paths.add(new SetPath(String.class, StringPath.class, "p")); paths.add(new SimplePath(String.class,"p")); paths.add(new StringPath("p")); paths.add(new TimePath(Time.class,"p")); for (Path<?> path : paths) { Path other = ExpressionUtils.path(path.getType(), "p"); assertEquals(path.toString(), path.accept(ToStringVisitor.DEFAULT, null)); assertEquals(path.hashCode(), other.hashCode()); assertEquals(path, other); assertNotNull(path.getMetadata()); assertNotNull(path.getType()); assertEquals(path, path.getRoot()); } }
public Query toHibernateQuery(Boolean count) { if (Boolean.TRUE.equals(count)) { select(countPath.count()); } else { select(select.build()); } where(whereClause.and(quickFilterWhereClause)); return createQuery(); }
/** * Compares the two relational paths using primary key columns * * @param right rhs of the comparison * @return this == right */ @Override public BooleanExpression eq(T right) { if (right instanceof RelationalPath) { return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey()); } else { return super.eq(right); } }
@Test public void createEnum() { assertNotNull(beanPath.createEnum("property", PropertyType.class)); }
@Test public void as_path() { SimplePath<BeanPathTest> simplePath = new SimplePath<BeanPathTest>(BeanPathTest.class, "p"); assertNotNull(beanPath.as(simplePath)); }
@SuppressWarnings("unchecked") @Test public void various() { List<DslExpression<?>> paths = new ArrayList<DslExpression<?>>(); paths.add(new ArrayPath(String[].class, "p")); paths.add(new BeanPath(Object.class, "p")); paths.add(new BooleanPath("p")); paths.add(new CollectionPath(String.class, StringPath.class, "p")); paths.add(new ComparablePath(String.class,"p")); paths.add(new DatePath(Date.class,"p")); paths.add(new DateTimePath(Date.class,"p")); paths.add(new EnumPath(ExampleEnum.class,"p")); paths.add(new ListPath(String.class, StringPath.class, "p")); paths.add(new MapPath(String.class, String.class, StringPath.class, "p")); paths.add(new NumberPath(Integer.class,"p")); paths.add(new SetPath(String.class, StringPath.class, "p")); paths.add(new SimplePath(String.class,"p")); paths.add(new StringPath("p")); paths.add(new TimePath(Time.class,"p")); for (DslExpression<?> expr : paths) { Path<?> o = ExpressionUtils.path(expr.getType(), "o"); assertEquals(ExpressionUtils.operation(expr.getType(), Ops.ALIAS, expr, o), expr.as("o")); Path p = ExpressionUtils.path(expr.getType(), "p"); assertEquals(ExpressionUtils.operation(expr.getType(), Ops.ALIAS, expr, p), expr.as(p)); } }
public Query toHibernateQuery(Boolean count) { if (Boolean.TRUE.equals(count)) { select(countPath.count()); } else { select(select.build()); } where(whereClause.and(quickFilterWhereClause)); return createQuery(); }
/** * Compares the two relational paths using primary key columns * * @param right rhs of the comparison * @return this == right */ @Override public BooleanExpression eq(Expression<? super T> right) { if (right instanceof RelationalPath) { return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey()); } else { return super.eq(right); } }
public QDefaultQueryMetadata(BeanPath<? extends DefaultQueryMetadata> entity) { super(entity.getType(), entity.getMetadata()); }
/** * Create a new Set typed path * * @param <A> * @param property property name * @param type property type * @return property path */ @SuppressWarnings("unchecked") protected <A, E extends SimpleExpression<? super A>> SetPath<A, E> createSet(String property, Class<? super A> type, Class<? super E> queryType, PathInits inits) { return add(new SetPath<A, E>(type, (Class) queryType, forProperty(property), inits)); }
@Test @Ignore public void as_class() { MyBeanPath otherPath = beanPath.as(MyBeanPath.class); assertEquals(beanPath, otherPath); assertTrue(otherPath.getMetadata().isRoot()); }
@SuppressWarnings("unchecked") @Test public void various_properties() { Path<?> parent = ExpressionUtils.path(Object.class, "parent"); List<Path<?>> paths = new ArrayList<Path<?>>(); paths.add(new ArrayPath(String[].class, parent, "p")); paths.add(new BeanPath(Object.class, parent, "p")); paths.add(new BooleanPath(parent, "p")); paths.add(new CollectionPath(String.class, StringPath.class, parent, "p")); paths.add(new ComparablePath(String.class, parent, "p")); paths.add(new DatePath(Date.class, parent, "p")); paths.add(new DateTimePath(Date.class, parent, "p")); paths.add(new EnumPath(ExampleEnum.class, parent, "p")); paths.add(new ListPath(String.class, StringPath.class, parent, "p")); paths.add(new MapPath(String.class, String.class, StringPath.class, parent, "p")); paths.add(new NumberPath(Integer.class, parent, "p")); paths.add(new SetPath(String.class, StringPath.class, parent, "p")); paths.add(new SimplePath(String.class, parent, "p")); paths.add(new StringPath(parent, "p")); paths.add(new TimePath(Time.class, parent, "p")); for (Path<?> path : paths) { Path other = ExpressionUtils.path(path.getType(), PathMetadataFactory.forProperty(parent, "p")); assertEquals(path.toString(), path.accept(ToStringVisitor.DEFAULT, Templates.DEFAULT)); assertEquals(path.hashCode(), other.hashCode()); assertEquals(path, other); assertNotNull(path.getMetadata()); assertNotNull(path.getType()); assertEquals(parent, path.getRoot()); } }
@Test public void instanceOf() { assertNotNull(beanPath.instanceOf(BeanPathTest.class)); }