* TODO: this code is not currently in use because there is no way to set up
* the cache. We may want to change what the cache is keyed on.
*/
private ObjectAdapter[] getInstancesFromCache(final PersistenceQuery persistenceQuery) {
final ObjectSpecification noSpec = persistenceQuery.getSpecification();
final PersistenceQueryBuiltIn builtIn = (PersistenceQueryBuiltIn) persistenceQuery;
final ObjectAdapter collection = cache.get(noSpec);
if (!collection.getSpecification().isCollection()) {
return new ObjectAdapter[0];
}
final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
final List<ObjectAdapter> instances = new ArrayList<ObjectAdapter>();
for (final ObjectAdapter instance : facet.iterable(collection)) {
if (builtIn.matches(instance)) {
instances.add(instance);
}
}
return instances.toArray(new ObjectAdapter[instances.size()]);
}