/*
* Copyright 2008 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.
* container.
*
* @author Erik Brakkee
- *
*/
public class ConnectRequiredProvidedEdgeFilter implements EdgeFilter {
-
private String client;
+
private String required;
+
private String server;
+
private String provided;
+ /**
+ * Creates a new ConnectRequiredProvidedEdgeFilter object.
+ *
+ */
public ConnectRequiredProvidedEdgeFilter(String aClient, String aRequired,
- String aServer, String aProvided) {
+ String aServer, String aProvided) {
client = aClient;
required = aRequired;
server = aServer;
provided = aProvided;
- if ( client == null ) {
- throw new IllegalArgumentException("Client component must be specified");
+
+ if (client == null) {
+ throw new IllegalArgumentException(
+ "Client component must be specified");
}
}
@Override
public boolean isViolated(Edge aEdge) {
- if (aEdge.getFrom() instanceof RequiredInterfaceNode
- && aEdge.getTo() instanceof ProvidedInterfaceNode) {
+ if (aEdge.getFrom() instanceof RequiredInterfaceNode &&
+ aEdge.getTo() instanceof ProvidedInterfaceNode) {
return isViolated((RequiredInterfaceNode) aEdge.getFrom(),
- (ProvidedInterfaceNode) aEdge.getTo());
+ (ProvidedInterfaceNode) aEdge.getTo());
}
+
return false;
}
private boolean isViolated(RequiredInterfaceNode aFrom,
- ProvidedInterfaceNode aTo) {
- if (client.equals(aFrom.getComponent().getName())
- && (required == null || required.equals(aFrom.getRequired()
- .getName()))) {
+ ProvidedInterfaceNode aTo) {
+ if (client.equals(aFrom.getComponent().getName()) &&
+ ((required == null) || required.equals(aFrom.getRequired()
+ .getName()))) {
// From part matches.
- if ( server == null ) {
+ if (server == null) {
return true; // all connections are eliminated
}
- if (server.equals(aTo.getComponent().getName())
- && (provided == null || provided.equals(aTo.getProvided()
- .getName()))) {
+
+ if (server.equals(aTo.getComponent().getName()) &&
+ ((provided == null) || provided.equals(aTo.getProvided()
+ .getName()))) {
// to part matches also
return false;
- }
- else {
+ } else {
// From matches and to doesn't so edgefilter is violated.
- return true;
+ return true;
}
} else {
// From part does not match, restriction does not apply.