/*
* @(#)AttributeList.java 1.28 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.management;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Represents a list of values for attributes of an MBean. The methods
* used for the insertion of {@link javax.management.Attribute
* Attribute} objects in the <CODE>AttributeList</CODE> overrides the
* corresponding methods in the superclass
* <CODE>ArrayList</CODE>. This is needed in order to insure that the
* objects contained in the <CODE>AttributeList</CODE> are only
* <CODE>Attribute</CODE> objects. This avoids getting an exception
* when retrieving elements from the <CODE>AttributeList</CODE>.
*
* @since 1.5
*/
/* We cannot extend ArrayList<Attribute> because our legacy
add(Attribute) method would then override add(E) in ArrayList<E>,
and our return value is void whereas ArrayList.add(E)'s is boolean.
Likewise for set(int,Attribute). Grrr. We cannot use covariance
to override the most important methods and have them return
Attribute, either, because that would break subclasses that
override those methods in turn (using the original return type
of Object). Finally, we cannot implement Iterable<Attribute>
so you could write
for (Attribute a : attributeList)
because ArrayList<> implements Iterable<> and the same class cannot
implement two versions of a generic interface. Instead we provide
the asList() method so you can write
for (Attribute a : attributeList.asList())
*/
public class AttributeList extends ArrayList<Object> {
private transient boolean typeSafe;
private transient boolean tainted;
/* Serial version */
private static final long serialVersionUID = -4077085769279709076L;
/**
* Constructs an empty <CODE>AttributeList</CODE>.
*/
public AttributeList() {
super();
}
/**
* Constructs an empty <CODE>AttributeList</CODE> with
* the initial capacity specified.
*
* @param initialCapacity the initial capacity of the
* <code>AttributeList</code>, as specified by {@link
* ArrayList#ArrayList(int)}.
*/
public AttributeList(int initialCapacity) {
super(initialCapacity);
}
/**
* Constructs an <CODE>AttributeList</CODE> containing the
* elements of the <CODE>AttributeList</CODE> specified, in the
* order in which they are returned by the
* <CODE>AttributeList</CODE>'s iterator. The
* <CODE>AttributeList</CODE> instance has an initial capacity of
* 110% of the size of the <CODE>AttributeList</CODE> specified.
*
* @param list the <code>AttributeList</code> that defines the initial
* contents of the new <code>AttributeList</code>.
*
* @see ArrayList#ArrayList(java.util.Collection)
*/
public AttributeList(AttributeList list) {
super(list);
}
/**
* Constructs an {@code AttributeList} containing the elements of the
* {@code List} specified, in the order in which they are returned by
* the {@code List}'s iterator.
*
* @param list the {@code List} that defines the initial contents of
* the new {@code AttributeList}.
*
* @exception IllegalArgumentException if the {@code list} parameter
* is {@code null} or if the {@code list} parameter contains any
* non-Attribute objects.
*
* @see ArrayList#ArrayList(java.util.Collection)
*
* @since 1.6
*/
=1= |