2 * Copyright 2008 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.system.graph.component;
18 import org.wamblee.system.graph.Edge;
19 import org.wamblee.system.graph.EdgeFilter;
20 import org.wamblee.system.graph.EdgeSelector;
21 import org.wamblee.system.graph.Node;
24 * Filter used to explicitly connect required and provided interfaces within a
27 * @author Erik Brakkee
30 public class ConnectExternalProvidedProvidedFilter implements EdgeFilter {
32 private String _externalProvided;
33 private String _component;
34 private String _provided;
36 public ConnectExternalProvidedProvidedFilter(String aExternalProvided, String aComponent,
38 _externalProvided = aExternalProvided;
39 _component = aComponent;
40 _provided = aProvided;
41 if ( _externalProvided == null ) {
42 throw new IllegalArgumentException("External provided interface name must be specified.");
44 if ( _component == null ) {
45 throw new IllegalArgumentException("Component name must be specified");
47 if ( _provided == null ) {
48 throw new IllegalArgumentException("Provided interface name of internal component must be specified");
53 public boolean isViolated(Edge aEdge) {
54 if (aEdge.getFrom() instanceof ExternalProvidedInterfaceNode
55 && aEdge.getTo() instanceof ProvidedInterfaceNode) {
56 return isViolated((ExternalProvidedInterfaceNode) aEdge.getFrom(),
57 (ProvidedInterfaceNode) aEdge.getTo());
62 private boolean isViolated(ExternalProvidedInterfaceNode aFrom,
63 ProvidedInterfaceNode aTo) {
64 if ( !aFrom.getName().equals(_externalProvided)) {
65 return false; // wrong provided interface.
67 if ( aTo.getComponent().getName().equals(_component) &&
68 aTo.getProvided().getName().equals(_provided) ) {