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;
23 * Filter used to explicitly connect required and provided interfaces
26 * @author Erik Brakkee
28 public class ConnectExternalProvidedProvidedFilter implements EdgeFilter {
32 private String externalProvided;
37 private String component;
42 private String provided;
45 * Creates a new ConnectExternalProvidedProvidedFilter object.
47 * @param aExternalProvided DOCUMENT ME!
48 * @param aComponent DOCUMENT ME!
49 * @param aProvided DOCUMENT ME!
51 public ConnectExternalProvidedProvidedFilter(String aExternalProvided,
52 String aComponent, String aProvided) {
53 externalProvided = aExternalProvided;
54 component = aComponent;
57 if (externalProvided == null) {
58 throw new IllegalArgumentException(
59 "External provided interface name must be specified.");
62 if (component == null) {
63 throw new IllegalArgumentException(
64 "Component name must be specified");
67 if (provided == null) {
68 throw new IllegalArgumentException(
69 "Provided interface name of internal component must be specified");
76 * @param aEdge DOCUMENT ME!
78 * @return DOCUMENT ME!
81 public boolean isViolated(Edge aEdge) {
82 if (aEdge.getFrom() instanceof ExternalProvidedInterfaceNode
83 && aEdge.getTo() instanceof ProvidedInterfaceNode) {
84 return isViolated((ExternalProvidedInterfaceNode) aEdge.getFrom(),
85 (ProvidedInterfaceNode) aEdge.getTo());
94 * @param aFrom DOCUMENT ME!
95 * @param aTo DOCUMENT ME!
97 * @return DOCUMENT ME!
99 private boolean isViolated(ExternalProvidedInterfaceNode aFrom,
100 ProvidedInterfaceNode aTo) {
101 if (!aFrom.getName().equals(externalProvided)) {
102 return false; // wrong provided interface.
105 if (aTo.getComponent().getName().equals(component)
106 && aTo.getProvided().getName().equals(provided)) {