- Resource type = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasType);
- if(type == null) continue;
- if(graph.isInstanceOf(parameter2, type)) {
- Resource context = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasBrowseContext);
- if(context == null) continue;
- String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.BrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY);
- if(allowedContexts != null)
- if(!Arrays.contains(allowedContexts, parameter3))
- continue;
- result.add(context);
- }
+ Collection<Resource> acceptedTypes = graph.getObjects(contribution, VP.BrowseContextContribution_HasType);
+ Collection<Resource> allTypes = graph.getTypes(parameter2);
+ if(Collections.disjoint(acceptedTypes, allTypes))
+ continue;
+
+ Resource context = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasBrowseContext);
+ if(context == null)
+ continue;
+
+ String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.BrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY);
+ if(allowedContexts != null && !Arrays.contains(allowedContexts, parameter3))
+ continue;
+
+ result.add(context);