Has extends SimpleQuery<O, A> { public Has(Attribute<O, A> attribute) { super(attribute); } Has(Attribute<O, A> attribute); @Override String toString(); @Override boolean equals(Object o);  }
@Test public void testExists() { IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(); Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") { public String getValue(Car car, QueryOptions queryOptions) { return car.name; } }; cars.addIndex(StandingQueryIndex.onQuery(has(NAME))); cars.addIndex(StandingQueryIndex.onQuery(not(has(NAME)))); cars.add(new Car(1, "ford focus", "great condition, low mileage", Arrays.asList("spare tyre", "sunroof"))); cars.add(new Car(2, null, "dirty and unreliable, flat tyre", Arrays.asList("spare tyre", "radio"))); cars.add(new Car(3, "honda civic", "has a flat tyre and high mileage", Arrays.asList("radio"))); Assert.assertEquals(cars.retrieve(has(NAME)).size(), 2); Assert.assertEquals(cars.retrieve(not(has(NAME))).size(), 1); }