needDrill = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
needDrill.add(desc);
} else {
+ if(relationType != null) {
+ if(!filterByRelationType(graph, desc, relationType))
+ continue;
+ }
if(result == null)
result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
result.add(desc);
}
}
- if(needDrill == null) {
- /*
- * All descriptors were already flat - just take case of filtering
- */
- if(relationType != null) {
- ArrayList<VariableConnectionPointDescriptor> filtered = new ArrayList<VariableConnectionPointDescriptor>(climbed.size());
- for(VariableConnectionPointDescriptor desc : climbed)
- if(filterByRelationType(graph, desc, relationType))
- filtered.add(desc);
- return filtered;
- } else {
- return climbed;
+ if(needDrill != null) {
+ /*
+ * There were some descriptors that require drill
+ */
+ for(VariableConnectionPointDescriptor top : needDrill) {
+ Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
+ if(drilled != null) {
+ for(VariableConnectionPointDescriptor drill : drilled) {
+ if(relationType != null) {
+ if(!filterByRelationType(graph, drill, relationType))
+ continue;
+ }
+ if(result == null)
+ result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
+ result.add(drill);
+ }
+ }
}
}
-
- /*
- * There were some descriptors that require drill
- */
- for(VariableConnectionPointDescriptor top : needDrill) {
- Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
- if(drilled != null) {
- for(VariableConnectionPointDescriptor drill : drilled) {
- if(relationType != null) {
- if(!filterByRelationType(graph, drill, relationType))
- continue;
- }
- if(result == null)
- result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
- result.add(drill);
- }
- }
+ if (result != null) {
+ return result;
+ } else {
+ return Collections.emptySet();
}
- return result;
-
}
private static boolean filterByRelationType(ReadGraph graph, VariableConnectionPointDescriptor desc, Resource relationType) throws DatabaseException {