01: /**
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */package javax.management.relation;
08:
09: import java.util.ArrayList;
10: import java.util.Iterator;
11: import java.util.List;
12:
13: /**
14: * @version $Revision: 1.8 $
15: */
16: public class RoleList extends ArrayList {
17: private static final long serialVersionUID = 5568344346499649313L;
18:
19: public RoleList() {
20: }
21:
22: public RoleList(int initialCapacity) {
23: super (initialCapacity);
24: }
25:
26: public RoleList(List list) throws IllegalArgumentException {
27: if (list == null)
28: throw new IllegalArgumentException(
29: "list argument must not be null");
30: for (Iterator listIterator = list.iterator(); listIterator
31: .hasNext();) {
32: Object currentListItem = listIterator.next();
33: if (!(currentListItem instanceof Role)) {
34: throw new IllegalArgumentException(
35: "Item added to the RoleList: "
36: + currentListItem
37: + " does not represent a Role");
38: }
39: add((Role) currentListItem);
40: }
41: }
42:
43: public void add(Role role) throws IllegalArgumentException {
44: if (role == null) {
45: throw new IllegalArgumentException("A role cannot be null");
46: }
47: super .add(role);
48: }
49:
50: public void add(int index, Role role)
51: throws IllegalArgumentException, IndexOutOfBoundsException {
52: if (role == null) {
53: throw new IllegalArgumentException(
54: "Cannot have a null role value");
55: }
56: super .add(index, role);
57: }
58:
59: public void set(int index, Role role)
60: throws IllegalArgumentException, IndexOutOfBoundsException {
61: if (role == null) {
62: throw new IllegalArgumentException(
63: "Cannot have a null role");
64: }
65: super .set(index, role);
66: }
67:
68: public boolean addAll(RoleList roleList)
69: throws IndexOutOfBoundsException {
70: if (roleList == null) {
71: return true;
72: }
73: return super .addAll(roleList);
74: }
75:
76: public boolean addAll(int index, RoleList roleList)
77: throws IllegalArgumentException, IndexOutOfBoundsException {
78: if (roleList == null) {
79: return true;
80: }
81: return super.addAll(index, roleList);
82: }
83: }
|