public void check(final Validation validation, Model model) { Set<BindingFeature> bfs = new HashSet<BindingFeature>( model.getObjects(BindingFeature.class)); Cluster<BindingFeature> groupping = new Cluster<BindingFeature>() { @Override public boolean match(BindingFeature a, BindingFeature b) { boolean ab = a.getBindsTo() != null && b.getBindsTo() != null && a.getBindsTo().isEquivalent(b.getBindsTo()); return !a.isEquivalent(b) && ab; } }; Set<Set<BindingFeature>> violations = groupping.cluster(bfs, Integer.MAX_VALUE); // report the error once for each cluster >1 for (Set<BindingFeature> s : violations) { if(s.size() > 1) { BindingFeature a = s.iterator().next(); error(validation, a, "inverse.functional.violated", false, "bindsTo", a.getBindsTo(), s); } } }
public void check(Model model, boolean fix) { Set<BindingFeature> bfs = new HashSet<BindingFeature>( model.getObjects(BindingFeature.class)); Cluster<BindingFeature> groupping = new Cluster<BindingFeature>() { @Override public boolean match(BindingFeature a, BindingFeature b) { boolean ab = a.getBindsTo() != null && b.getBindsTo() != null && a.getBindsTo().isEquivalent(b.getBindsTo()); return !a.isEquivalent(b) && ab; } }; Set<Set<BindingFeature>> violations = groupping.cluster(bfs, Integer.MAX_VALUE); // report the error once for each cluster >1 for (Set<BindingFeature> s : violations) { if(violations.size() > 1) { BindingFeature a = s.iterator().next(); error(a, "inverse.functional.violated", false, "bindsTo", a.getBindsTo(), BiopaxValidatorUtils.getIdListAsString(s)); } } }