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.core;
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
24 * Composite restriction that wraps a number of other restrictions. The restriction is
25 * violated if one of the contained restrictions is violated.
27 * @author Erik Brakkee
30 public class CompositeInterfaceRestriction implements InterfaceRestriction {
32 private List<InterfaceRestriction> _restrictions;
35 * Constructs the restriction.
37 public CompositeInterfaceRestriction() {
38 _restrictions = new ArrayList<InterfaceRestriction>();
42 * Constructs the restriction.
43 * @param aRestrictions List of contained restrictions.
45 public CompositeInterfaceRestriction(Collection<InterfaceRestriction> aRestrictions) {
47 _restrictions.addAll(aRestrictions);
52 * @param aRestriction Restriction.
53 * @return Reference to this composite restriction to allow call chaining.
55 public CompositeInterfaceRestriction add(InterfaceRestriction aRestriction) {
56 _restrictions.add(aRestriction);
61 public boolean isViolated(Component aClient, RequiredInterface aRequired,
62 Component aServer, ProvidedInterface aProvided) {
63 for (InterfaceRestriction restriction: _restrictions) {
64 if ( restriction.isViolated(aClient, aRequired, aServer, aProvided)) {