use of eu.esdihumboldt.hale.common.instance.model.ext.InstanceCollection2 in project hale by halestudio.
the class FilteredInstanceCollection method applyFilter.
/**
* Create an instance collection that applies a filter to the given instance
* collection.
*
* @param instances the instance collection to filter
* @param filter the filter
* @return the filtered instance collection
*/
public static InstanceCollection applyFilter(InstanceCollection instances, Filter filter) {
if (filter instanceof TypeFilter && instances instanceof InstanceCollection2) {
/*
* For type filters check if we can make use of fan-out.
*/
InstanceCollection2 instances2 = (InstanceCollection2) instances;
if (instances2.supportsFanout()) {
TypeDefinition type = ((TypeFilter) filter).getType();
InstanceCollection result = instances2.fanout().get(type);
if (result == null) {
result = EmptyInstanceCollection.INSTANCE;
}
return result;
}
}
// create a filtered collection
return new FilteredInstanceCollection(instances, filter);
}
Aggregations