@Test public void testSubjectIdentifiers() { LocatorIF locA = makeLocator("A"); LocatorIF locB = makeLocator("B"); TopicIF topicA = getTopic("A"); TopicIF topicB = getTopic("B"); SubjectIdentityDecider decider = new SubjectIdentityDecider(locA); Assert.assertTrue("Decider did not recognize topic", decider.ok(topicA)); Assert.assertTrue("Decider ok-d topic with wrong identifier", !decider.ok(topicB)); }
@Override public boolean ok(T object) { if (object instanceof TopicIF) { TopicIF topic = (TopicIF) object; if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } if (object instanceof TypedIF) { TopicIF topic = ((TypedIF) object).getType(); if (topic == null) return false; return topic.getSubjectIdentifiers().contains(subject_identifier); } else if (object instanceof TopicIF) { Iterator<TopicIF> it = ((TopicIF) object).getTypes().iterator(); while (it.hasNext()) { TopicIF topic = it.next(); if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } } return false; }
SubjectIdentityDecider implements DeciderIF<T> { @Override public boolean ok(T object) { if (object instanceof TopicIF) { TopicIF topic = (TopicIF) object; if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } if (object instanceof TypedIF) { TopicIF topic = ((TypedIF) object).getType(); if (topic == null) return false; return topic.getSubjectIdentifiers().contains(subject_identifier); } else if (object instanceof TopicIF) { Iterator<TopicIF> it = ((TopicIF) object).getTypes().iterator(); while (it.hasNext()) { TopicIF topic = it.next(); if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } } return false; } }
SubjectIdentityDecider implements DeciderIF<T> { @Override public boolean ok(T object) { if (object instanceof TopicIF) { TopicIF topic = (TopicIF) object; if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } if (object instanceof TypedIF) { TopicIF topic = ((TypedIF) object).getType(); if (topic == null) return false; return topic.getSubjectIdentifiers().contains(subject_identifier); } else if (object instanceof TopicIF) { Iterator<TopicIF> it = ((TopicIF) object).getTypes().iterator(); while (it.hasNext()) { TopicIF topic = it.next(); if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } } return false; } SubjectIdentityDecider(LocatorIF subject_identifier); }
SubjectIdentityDecider implements DeciderIF<T> { @Override public boolean ok(T object) { if (object instanceof TopicIF) { TopicIF topic = (TopicIF) object; if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } if (object instanceof TypedIF) { TopicIF topic = ((TypedIF) object).getType(); if (topic == null) return false; return topic.getSubjectIdentifiers().contains(subject_identifier); } else if (object instanceof TopicIF) { Iterator<TopicIF> it = ((TopicIF) object).getTypes().iterator(); while (it.hasNext()) { TopicIF topic = it.next(); if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } } return false; } SubjectIdentityDecider(LocatorIF subject_identifier); @Override boolean ok(T object); }
SubjectIdentityDecider implements DeciderIF<T> { @Override public boolean ok(T object) { if (object instanceof TopicIF) { TopicIF topic = (TopicIF) object; if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } if (object instanceof TypedIF) { TopicIF topic = ((TypedIF) object).getType(); if (topic == null) return false; return topic.getSubjectIdentifiers().contains(subject_identifier); } else if (object instanceof TopicIF) { Iterator<TopicIF> it = ((TopicIF) object).getTypes().iterator(); while (it.hasNext()) { TopicIF topic = it.next(); if (topic.getSubjectIdentifiers().contains(subject_identifier)) return true; } } return false; } SubjectIdentityDecider(LocatorIF subject_identifier); @Override boolean ok(T object);  }