/*
- * Copyright 2008 the original author or authors.
- *
+ * Copyright 2005-2010 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.system.graph.component;
import org.wamblee.general.Pair;
import java.util.ArrayList;
import java.util.List;
-
/**
- * Represents a component graph and provides the bridge from the component
- * model to a graph model. The graph model is easier to work with to implement
- * specific actions and validations than the component model.
+ * Represents a component graph and provides the bridge from the component model
+ * to a graph model. The graph model is easier to work with to implement
+ * specific actions and validations than the component model.
*/
public class ComponentGraph extends Graph {
- /**
- * DOCUMENT ME!
- */
private boolean isLinked;
- /**
- * DOCUMENT ME!
- */
private CompositeEdgeFilter edgeFilter;
-/**
- * Constructs an empty component graph.
+ /**
+ * Constructs an empty component graph.
*/
public ComponentGraph() {
- isLinked = false;
- edgeFilter = new CompositeEdgeFilter();
+ isLinked = false;
+ edgeFilter = new CompositeEdgeFilter();
}
/**
- * Adds an externally required interface of a container. This
- * should be called before any components of the container are added.
- *
- * @param aComponent Component requiring the interface.
- * @param aInterface Required interface.
+ * Adds an externally required interface of a container. This should be
+ * called before any components of the container are added.
+ *
+ * @param aComponent
+ * Component requiring the interface.
+ * @param aInterface
+ * Required interface.
*/
public void addRequiredInterface(Component aComponent,
RequiredInterface aInterface) {
}
/**
- * Adds an externally provided interface of a container. This
- * should be called after all components of the container have been added.
- *
- * @param aComponent Component providing the interface.
- * @param aInterface Provided interface.
+ * Adds an externally provided interface of a container. This should be
+ * called after all components of the container have been added.
+ *
+ * @param aComponent
+ * Component providing the interface.
+ * @param aInterface
+ * Provided interface.
*/
public void addProvidedInterface(Component aComponent,
ProvidedInterface aInterface) {
}
/**
- * Links provided and required interfaces together in the component
- * model based on the graph model.
+ * Links provided and required interfaces together in the component model
+ * based on the graph model.
*/
public void link() {
if (isLinked) {
}
/**
- * Finds a list of mappings of external provided interface to
- * internal provided interface.
- *
+ * Finds a list of mappings of external provided interface to internal
+ * provided interface.
+ *
* @return List of pairs of external to internal interface.
*/
public List<Pair<ProvidedInterface, ProvidedInterface>> findExternalProvidedInterfaceMapping() {
List<Pair<ProvidedInterface, ProvidedInterface>> result = new ArrayList<Pair<ProvidedInterface, ProvidedInterface>>();
for (Edge edge : getEdges()) {
- if (edge.getFrom() instanceof ExternalProvidedInterfaceNode
- && edge.getTo() instanceof ProvidedInterfaceNode) {
+ if (edge.getFrom() instanceof ExternalProvidedInterfaceNode &&
+ edge.getTo() instanceof ProvidedInterfaceNode) {
result.add(new Pair<ProvidedInterface, ProvidedInterface>(
- ((ExternalProvidedInterfaceNode) edge.getFrom())
- .getProvided(),
- ((ProvidedInterfaceNode) edge.getTo()).getProvided()));
+ ((ExternalProvidedInterfaceNode) edge.getFrom())
+ .getProvided(), ((ProvidedInterfaceNode) edge.getTo())
+ .getProvided()));
}
}
}
/**
- * Adds a component by adding required interfaces, components, and
- * provided interfaces.
- *
- * @param aComponent Component to add.
+ * Adds a component by adding required interfaces, components, and provided
+ * interfaces.
+ *
+ * @param aComponent
+ * Component to add.
*/
public void addComponent(Component<?> aComponent) {
- // Add required interfaces.
- Node compNode = new ComponentNode(aComponent);
+ // Add required interfaces.
+ Node compNode = new ComponentNode(aComponent);
List<Node> requiredNodes = new ArrayList<Node>();
for (RequiredInterface required : aComponent.getRequiredInterfaces()) {
// Add the component
addNode(compNode);
- // Edges from component to required interface.
+ // Edges from component to required interface.
for (Node reqNode : requiredNodes) {
addEdge(new DefaultEdge(compNode, reqNode));
}
}
}
- /**
- * DOCUMENT ME!
- *
- * @param aEdgeFilter DOCUMENT ME!
- */
public void addEdgeFilter(CompositeEdgeFilter aEdgeFilter) {
edgeFilter.add(aEdgeFilter);
}