X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fgraph%2Fcomponent%2FComponentGraph.java;h=b41c41c81445d277165fed2eb7f44414b224d944;hb=ee26f9544a0bf7f49390990c68981676e0e51014;hp=be861f309255da4deb64ed63cd12e63f15ab56da;hpb=080d7c58c8228aeefc00960b8fd50cf193a04c0c;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java index be861f30..b41c41c8 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java @@ -19,11 +19,10 @@ import java.util.ArrayList; import java.util.List; import org.wamblee.general.Pair; -import org.wamblee.system.container.CompositeInterfaceRestriction; -import org.wamblee.system.container.InterfaceRestriction; import org.wamblee.system.core.Component; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; +import org.wamblee.system.graph.CompositeEdgeFilter; import org.wamblee.system.graph.DefaultEdge; import org.wamblee.system.graph.Edge; import org.wamblee.system.graph.Graph; @@ -37,21 +36,15 @@ import org.wamblee.system.graph.Node; */ public class ComponentGraph extends Graph { - private CompositeInterfaceRestriction _restriction; + private boolean _isLinked; + private CompositeEdgeFilter _edgeFilter; /** * Constructs an empty component graph. */ public ComponentGraph() { - _restriction = new CompositeInterfaceRestriction(); - } - - /** - * Adds a restriction that must be satisfied by the component model. - * @param aRestriction Restriction. - */ - public void addRestriction(InterfaceRestriction aRestriction) { - _restriction.add(aRestriction); + _isLinked = false; + _edgeFilter = new CompositeEdgeFilter(); } /** @@ -80,7 +73,7 @@ public class ComponentGraph extends Graph { */ public void validate() { extend(new RequiredProvidedEdgeFactory()); - accept(new ApplyRestrictionsVisitor(this, _restriction)); + applyFilter(_edgeFilter); accept(new CheckRequiredProvidedMultiplicityVisitor(this)); accept(new CheckExternallyRequiredVisitor(this)); accept(new CheckExternallyProvidedVisitor(this)); @@ -91,8 +84,12 @@ public class ComponentGraph extends Graph { * Links provided and required interfaces together in the component * model based on the graph model. */ - public void link() { + public void link() { + if ( _isLinked ) { + return; + } accept(new LinkVisitor()); + _isLinked = true; } /** @@ -120,7 +117,7 @@ public class ComponentGraph extends Graph { * provided interfaces. * @param aComponent Component to add. */ - public void addComponent(Component aComponent) { + public void addComponent(Component aComponent) { // Add required interfaces. Node compNode = new ComponentNode(aComponent); List requiredNodes = new ArrayList(); @@ -150,4 +147,8 @@ public class ComponentGraph extends Graph { addEdge(new DefaultEdge(provNode, compNode)); } } + + public void addEdgeFilter(CompositeEdgeFilter aEdgeFilter) { + _edgeFilter.add(aEdgeFilter); + } }