@Test
public void testReflectiveAttribute() {

    // Create an indexed collection (note: could alternatively use CQEngine.copyFrom() existing collection)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();
    // Define an attribute which will use reflection...
    Attribute<Car, String> NAME = ReflectiveAttribute.forField(Car.class, String.class, "name");
    cars.addIndex(HashIndex.onAttribute(NAME));
    // Add some objects to the collection...
    cars.add(new Car(1, "ford focus", "great condition, low mileage", Arrays.asList("spare tyre", "sunroof")));
    cars.add(new Car(2, "ford taurus", "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(equal(NAME, "honda civic")).size(), 1);
}