示例#1
0
  @Override
  public ResultSet filter(Criteria... expressions) {
    Group and = ObjectFilter.and(expressions);

    ResultSet results = cache.get(and);

    if (results != null) {
      cache.put(and, results);
      return results;
    }

    results = super.filter(expressions);

    cache.put(and, results);

    return results;
  }
示例#2
0
  @Test
  public void testQuery() throws Exception {
    repo.query(
        ObjectFilter.eq("ints", 1),
        ObjectFilter.eq("floats", 1.1f),
        ObjectFilter.eq("doubles", 1.1),
        ObjectFilter.eq("shorts", (short) 1),
        ObjectFilter.eq("chars", 'c'),
        ObjectFilter.eq("longs", 1L),
        ObjectFilter.eq("bytes", (byte) 1));

    repo.query(
        ObjectFilter.gt("ints", 1),
        ObjectFilter.gt("floats", 1.1f),
        ObjectFilter.gt("doubles", 1.1),
        ObjectFilter.gt("shorts", (short) 1),
        ObjectFilter.gt("chars", 'c'),
        ObjectFilter.gt("longs", 1L),
        ObjectFilter.gt("bytes", (byte) 1));

    repo.query(
        ObjectFilter.lt("ints", 1),
        ObjectFilter.lt("floats", 1.1f),
        ObjectFilter.lt("doubles", 1.1),
        ObjectFilter.lt("shorts", (short) 1),
        ObjectFilter.lt("chars", 'c'),
        ObjectFilter.lt("longs", 1L),
        ObjectFilter.lt("bytes", (byte) 1));

    repo.query(
        ObjectFilter.gte("ints", 1),
        ObjectFilter.gte("floats", 1.1f),
        ObjectFilter.gte("doubles", 1.1),
        ObjectFilter.gte("shorts", (short) 1),
        ObjectFilter.gte("chars", 'c'),
        ObjectFilter.gte("longs", 1L),
        ObjectFilter.gte("bytes", (byte) 1));

    repo.query(
        ObjectFilter.lte("ints", 1),
        ObjectFilter.lte("floats", 1.1f),
        ObjectFilter.lte("doubles", 1.1),
        ObjectFilter.lte("shorts", (short) 1),
        ObjectFilter.lte("chars", 'c'),
        ObjectFilter.lte("longs", 1L),
        ObjectFilter.lte("bytes", (byte) 1));

    repo.query(
        ObjectFilter.in("ints", 1, 2, 3),
        ObjectFilter.in("floats", 1.1f, 1.2f),
        ObjectFilter.in("doubles", 1.1, 2.2),
        ObjectFilter.in("shorts", (short) 1, (short) 2, (short) 3),
        ObjectFilter.in("chars", 'a', 'b', 'c'),
        ObjectFilter.in("longs", 1L, 2L, 3L),
        ObjectFilter.in("bytes", (byte) 1, (byte) 2, (byte) 3));

    repo.query(
        ObjectFilter.between("ints", 1, 2),
        ObjectFilter.between("floats", 1.1f, 1.2f),
        ObjectFilter.between("doubles", 1.1, 2.2),
        ObjectFilter.between("shorts", (short) 1, (short) 2),
        ObjectFilter.between("chars", 'a', 'b'),
        ObjectFilter.between("longs", 1L, 2L),
        ObjectFilter.between("bytes", (byte) 1, (byte) 2));

    repo.query(
        ObjectFilter.notIn("ints", 1, 2, 3),
        ObjectFilter.notIn("floats", 1.1f, 1.2f),
        ObjectFilter.notIn("doubles", 1.1, 2.2),
        ObjectFilter.notIn("shorts", 1, 2, 3),
        ObjectFilter.notIn("chars", 'a', 'b', 'c'),
        ObjectFilter.notIn("longs", 1L, 2L, 3L),
        ObjectFilter.notIn("bytes", 1, 2, 3));

    repo.query(ObjectFilter.startsWith("strings", "foo"));

    repo.query(ObjectFilter.endsWith("strings", "foo"));
  }
示例#3
0
 public static boolean orTest(Object obj, Criteria... exp) {
   return ObjectFilter.or(exp).test(obj);
 }