@Test public void adding_duplicate_objects_in_scope() throws Exception { TestScope s = new TestScope(); s.add(new ScopedObject("s1")); s.add(new Scope<>("s2")); try { s.add(new ScopedObject("s1")); fail(); } catch (IllegalStateException e) { } try { s.add(new TestScope("s1")); fail(); } catch (IllegalStateException e) { } try { s.add(new ScopedObject("s2")); fail(); } catch (IllegalStateException e) { } try { s.add(new TestScope("s2")); fail(); } catch (IllegalStateException e) { } }
public synchronized final void add(Scope<T> scope) { Ensure.not_null(scope); Ensure.is_null(scope.m_parent); Ensure.not_null(scope.m_name); if (m_objects.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has an object " + "named '" + scope.m_name + "'."); } if (m_sub_scopes.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has a sub scope " + "named '" + scope.m_name + "'."); } check_add(scope); m_sub_scopes.put(scope.m_name, scope); scope.m_parent = this; }
Scope { public synchronized final void add(Scope<T> scope) { Ensure.not_null(scope); Ensure.is_null(scope.m_parent); Ensure.not_null(scope.m_name); if (m_objects.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has an object " + "named '" + scope.m_name + "'."); } if (m_sub_scopes.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has a sub scope " + "named '" + scope.m_name + "'."); } check_add(scope); m_sub_scopes.put(scope.m_name, scope); scope.m_parent = this; } }
Scope { public synchronized final void add(Scope<T> scope) { Ensure.not_null(scope); Ensure.is_null(scope.m_parent); Ensure.not_null(scope.m_name); if (m_objects.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has an object " + "named '" + scope.m_name + "'."); } if (m_sub_scopes.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has a sub scope " + "named '" + scope.m_name + "'."); } check_add(scope); m_sub_scopes.put(scope.m_name, scope); scope.m_parent = this; } Scope(String name); }
Scope { public synchronized final void add(Scope<T> scope) { Ensure.not_null(scope); Ensure.is_null(scope.m_parent); Ensure.not_null(scope.m_name); if (m_objects.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has an object " + "named '" + scope.m_name + "'."); } if (m_sub_scopes.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has a sub scope " + "named '" + scope.m_name + "'."); } check_add(scope); m_sub_scopes.put(scope.m_name, scope); scope.m_parent = this; } Scope(String name); final String name(); final Scope<T> parent(); final HierarchicalName absolute_hname(); synchronized final void add(Scope<T> scope); synchronized final void add(T obj); synchronized T find(String name); synchronized Scope<T> find_scope(String name); synchronized T find(HierarchicalName hn); synchronized Scope<T> find_scope(HierarchicalName hn); synchronized Set<T> all(); synchronized final void link(Scope<T> scope); synchronized Set<T> all_recursive(); synchronized boolean child_scope_of(Scope<?> scope); static Scope<?> common_inner_most_parent_scope(
			Set<? extends Scope<?>> scopes); }
Scope { public synchronized final void add(Scope<T> scope) { Ensure.not_null(scope); Ensure.is_null(scope.m_parent); Ensure.not_null(scope.m_name); if (m_objects.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has an object " + "named '" + scope.m_name + "'."); } if (m_sub_scopes.get(scope.m_name) != null) { throw new IllegalStateException("Scope already has a sub scope " + "named '" + scope.m_name + "'."); } check_add(scope); m_sub_scopes.put(scope.m_name, scope); scope.m_parent = this; } Scope(String name); final String name(); final Scope<T> parent(); final HierarchicalName absolute_hname(); synchronized final void add(Scope<T> scope); synchronized final void add(T obj); synchronized T find(String name); synchronized Scope<T> find_scope(String name); synchronized T find(HierarchicalName hn); synchronized Scope<T> find_scope(HierarchicalName hn); synchronized Set<T> all(); synchronized final void link(Scope<T> scope); synchronized Set<T> all_recursive(); synchronized boolean child_scope_of(Scope<?> scope); static Scope<?> common_inner_most_parent_scope(
			Set<? extends Scope<?>> scopes);  }