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.Arrays;
20 import java.util.Iterator;
21 import java.util.List;
23 public class ReadWriteNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
25 protected List<T> _interfaces;
27 public ReadWriteNamedInterfaces() {
28 _interfaces = new ArrayList<T>();
31 public ReadWriteNamedInterfaces(T[] aInterfaces) {
32 _interfaces = new ArrayList<T>();
33 _interfaces.addAll(Arrays.asList(aInterfaces));
37 return _interfaces.size();
40 public T get(int aIndex) {
41 return _interfaces.get(aIndex);
44 public T get(String aName) {
45 for (T intf: _interfaces) {
46 if ( intf.getName().equals(aName)) {
53 public void add(T aInterface) {
54 _interfaces.add(aInterface);
58 public Iterator<T> iterator() {
59 return _interfaces.iterator();