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.7 $
15: */
16: public class RoleUnresolvedList extends ArrayList {
17: private static final long serialVersionUID = 4054902803091433324L;
18:
19: public RoleUnresolvedList() {
20: }
21:
22: public RoleUnresolvedList(int initialCapacity) {
23: super (initialCapacity);
24: }
25:
26: // method accepts any list but list may only contain elements of RoleUnresolved
27: public RoleUnresolvedList(List list)
28: throws IllegalArgumentException {
29: if (list == null) {
30: throw new IllegalArgumentException("List cannot be null");
31: }
32: for (Iterator i = list.iterator(); i.hasNext();) {
33: Object currentIteration = i.next();
34: if (!(currentIteration instanceof RoleUnresolved)) {
35: throw new IllegalArgumentException(
36: "All elements in the list must be an instance of RoleUnresolved");
37: }
38: add((RoleUnresolved) currentIteration);
39: }
40: }
41:
42: public void add(RoleUnresolved roleUnresolved)
43: throws IllegalArgumentException {
44: if (roleUnresolved == null) {
45: throw new IllegalArgumentException(
46: "RoleUnresolved cannot be null");
47: }
48: super .add(roleUnresolved);
49: }
50:
51: public void add(int index, RoleUnresolved roleUnresolved)
52: throws IllegalArgumentException, IndexOutOfBoundsException {
53: if (roleUnresolved == null) {
54: throw new IllegalArgumentException(
55: "RoleUnresolved cannot be null");
56: }
57: super .add(index, roleUnresolved);
58: }
59:
60: public void set(int index, RoleUnresolved roleUnresolved)
61: throws IllegalArgumentException, IndexOutOfBoundsException {
62: if (roleUnresolved == null) {
63: throw new IllegalArgumentException(
64: "RoleUnresolved cannot be null");
65: }
66: super .set(index, roleUnresolved);
67: }
68:
69: public boolean addAll(RoleUnresolvedList roleUnresolvedList)
70: throws IndexOutOfBoundsException {
71: if (roleUnresolvedList == null)
72: return true;
73: return super .addAll(roleUnresolvedList);
74: }
75:
76: public boolean addAll(int index,
77: RoleUnresolvedList roleUnresolvedList)
78: throws IllegalArgumentException, IndexOutOfBoundsException {
79: if (roleUnresolvedList == null)
80: return true;
81: return super.addAll(index, roleUnresolvedList);
82: }
83: }
|