import java.util.Iterator;
import java.util.List;
-public class ReadWriteNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
-
- protected List<T> _interfaces;
+public class ReadWriteNamedInterfaces<T extends NamedInterface> extends ArrayList<T> {
public ReadWriteNamedInterfaces() {
- _interfaces = new ArrayList<T>();
+ // Empty.
}
public ReadWriteNamedInterfaces(T[] aInterfaces) {
- _interfaces = new ArrayList<T>();
- _interfaces.addAll(Arrays.asList(aInterfaces));
- }
-
- public int size() {
- return _interfaces.size();
+ addAll(Arrays.asList(aInterfaces));
}
-
- public T get(int aIndex) {
- return _interfaces.get(aIndex);
- }
-
+
public T get(String aName) {
- for (T intf: _interfaces) {
+ for (T intf: this) {
if ( intf.getName().equals(aName)) {
return intf;
}
}
return null;
}
-
- public void add(T aInterface) {
- _interfaces.add(aInterface);
- }
-
- @Override
- public Iterator<T> iterator() {
- return _interfaces.iterator();
- }
-
}