01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Original code by *
09: *****************************************************************************/package org.picocontainer.gems.monitors.prefuse;
10:
11: import java.util.HashSet;
12: import java.util.Set;
13:
14: import org.picocontainer.gems.monitors.ComponentDependencyMonitor.Dependency;
15:
16: /**
17: * Understands non-duplicated dependencies.
18: *
19: * @author Peter Barry
20: * @author Kent R. Spillner
21: */
22: public final class DependencySet implements ComponentDependencyListener {
23:
24: private final Set uniqueDependencies = new HashSet();
25:
26: private final ComponentDependencyListener listener;
27:
28: public DependencySet(ComponentDependencyListener listener) {
29: this .listener = listener;
30: }
31:
32: public void addDependency(Dependency dependency) {
33: if (uniqueDependencies.add(dependency)) {
34: listener.addDependency(dependency);
35: }
36: }
37:
38: public Dependency[] getDependencies() {
39: return (Dependency[]) uniqueDependencies
40: .toArray(new Dependency[uniqueDependencies.size()]);
41: }
42: }
|