Search in sources :

Example 96 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class OrPredicate method negate.

@Override
public Predicate negate() {
    int size = predicates.length;
    Predicate[] inners = new Predicate[size];
    for (int i = 0; i < size; i++) {
        Predicate original = predicates[i];
        Predicate negated;
        if (original instanceof NegatablePredicate) {
            negated = ((NegatablePredicate) original).negate();
        } else {
            negated = new NotPredicate(original);
        }
        inners[i] = negated;
    }
    AndPredicate andPredicate = new AndPredicate(inners);
    return andPredicate;
}
Also used : IndexAwarePredicate(com.hazelcast.query.IndexAwarePredicate) Predicate(com.hazelcast.query.Predicate) VisitablePredicate(com.hazelcast.query.VisitablePredicate)

Example 97 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddLocalEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate.

@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate() throws Exception {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addLocalEntryListener(mapListener, predicate, null, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 98 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddLocalEntryListenerWithMapListenerAndPredicate_NullPredicate.

@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListenerWithMapListenerAndPredicate_NullPredicate() throws Exception {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addLocalEntryListener(mapListener, predicate, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 99 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddLocalEntryListenerWithEntryListenerAndPredicateAndKey_NullPredicate.

@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListenerWithEntryListenerAndPredicateAndKey_NullPredicate() throws Exception {
    EntryListener entryListener = new TestEntryListener();
    Predicate predicate = null;
    map.addLocalEntryListener(entryListener, predicate, null, true);
}
Also used : EntryListener(com.hazelcast.core.EntryListener) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 100 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapMBean method values.

@ManagedAnnotation(value = "values", operation = true)
public String values(String query) {
    Collection coll;
    if (query != null && !query.isEmpty()) {
        Predicate predicate = new SqlPredicate(query);
        coll = managedObject.values(predicate);
    } else {
        coll = managedObject.values();
    }
    StringBuilder buf = new StringBuilder();
    if (coll.size() == 0) {
        buf.append("Empty");
    } else {
        buf.append("[");
        for (Object obj : coll) {
            buf.append(obj);
            buf.append(", ");
        }
        buf.replace(buf.length() - 1, buf.length(), "]");
    }
    return buf.toString();
}
Also used : Collection(java.util.Collection) SqlPredicate(com.hazelcast.query.SqlPredicate) Predicate(com.hazelcast.query.Predicate) SqlPredicate(com.hazelcast.query.SqlPredicate)

Aggregations

Predicate (com.hazelcast.query.Predicate)160 Test (org.junit.Test)125 QuickTest (com.hazelcast.test.annotation.QuickTest)124 ParallelTest (com.hazelcast.test.annotation.ParallelTest)107 TruePredicate (com.hazelcast.query.TruePredicate)41 SqlPredicate (com.hazelcast.query.SqlPredicate)33 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)23 PredicateBuilder (com.hazelcast.query.PredicateBuilder)19 EntryListener (com.hazelcast.core.EntryListener)16 MapListener (com.hazelcast.map.listener.MapListener)16 EntryObject (com.hazelcast.query.EntryObject)14 IndexAwarePredicate (com.hazelcast.query.IndexAwarePredicate)12 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)10 Value (com.hazelcast.query.SampleObjects.Value)9 PredicateTestUtils.createMockVisitablePredicate (com.hazelcast.query.impl.predicates.PredicateTestUtils.createMockVisitablePredicate)9 ArrayList (java.util.ArrayList)9 EntryEvent (com.hazelcast.core.EntryEvent)8 MapListenerAdapter (com.hazelcast.map.impl.MapListenerAdapter)8 ValueType (com.hazelcast.query.SampleObjects.ValueType)7