Class DescriptorList<T extends Describable<T>>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Descriptor<T>>
-
- hudson.util.DescriptorList<T>
-
- All Implemented Interfaces:
Iterable<Descriptor<T>>,Collection<Descriptor<T>>,List<Descriptor<T>>
public final class DescriptorList<T extends Describable<T>> extends AbstractList<Descriptor<T>>
List ofDescriptors.Before Hudson 1.286, this class stored
Descriptors directly, but since 1.286, this class works in two modes that are rather different.One is the compatibility mode, where it works just like pre 1.286 and store everything locally, disconnected from any of the additions of 1.286. This is necessary for situations where
DescriptorListis owned by pre-1.286 plugins where this class doesn't know 'T'. In this mode,legacyis non-null buttypeis null.The other mode is the new mode, where the
Descriptors are actually stored inExtensionList(seeJenkins.getDescriptorList(Class)) and this class acts as a view to it. This enables bi-directional interoperability — both descriptors registered automatically and descriptors registered manually are visible from bothDescriptorListandExtensionList. In this mode,legacyis null buttypeis non-null.The number of plugins that define extension points are limited, so we expect to be able to remove this dual behavior first, then when everyone stops using
DescriptorList, we can remove this class altogether.- Since:
- 1.161
- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description DescriptorList(Descriptor<T>... descriptors)Deprecated.As of 1.286.DescriptorList(Class<T> type)Creates aDescriptorListbacked byExtensionList.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, Descriptor<T> element)Deprecated.As of 1.286.booleanadd(Descriptor<T> d)Deprecated.As of 1.286.Descriptor<T>find(String fqcn)Deprecated.Underspecified what the parameter is.Descriptor<T>findByName(String id)Finds a descriptor by theirDescriptor.getId().Descriptor<T>get(int index)Iterator<Descriptor<T>>iterator()voidload(Class<? extends Describable> c)No-op method used to force the class initialization of the given class.TnewInstanceFromRadioList(net.sf.json.JSONObject config)Creates a new instance of aDescribablefrom the structured form submission data posted by a radio button group.TnewInstanceFromRadioList(net.sf.json.JSONObject parent, String name)Creates a new instance of aDescribablefrom the structured form submission data posted by a radio button group.booleanremove(Object o)intsize()-
Methods inherited from class java.util.AbstractList
addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
DescriptorList
@Deprecated public DescriptorList(Descriptor<T>... descriptors)
Deprecated.As of 1.286. UseDescriptorList(Class)instead.This will create a legacyDescriptorListthat is disconnected fromExtensionList.
-
DescriptorList
public DescriptorList(Class<T> type)
Creates aDescriptorListbacked byExtensionList.
-
-
Method Detail
-
get
public Descriptor<T> get(int index)
- Specified by:
getin interfaceList<T extends Describable<T>>- Specified by:
getin classAbstractList<Descriptor<T extends Describable<T>>>
-
size
public int size()
- Specified by:
sizein interfaceCollection<T extends Describable<T>>- Specified by:
sizein interfaceList<T extends Describable<T>>- Specified by:
sizein classAbstractCollection<Descriptor<T extends Describable<T>>>
-
iterator
public Iterator<Descriptor<T>> iterator()
- Specified by:
iteratorin interfaceCollection<T extends Describable<T>>- Specified by:
iteratorin interfaceIterable<T extends Describable<T>>- Specified by:
iteratorin interfaceList<T extends Describable<T>>- Overrides:
iteratorin classAbstractList<Descriptor<T extends Describable<T>>>
-
add
@Deprecated public boolean add(Descriptor<T> d)
Deprecated.As of 1.286. PutExtensionon your descriptor to have it auto-registered, instead of registering a descriptor manually.- Specified by:
addin interfaceCollection<T extends Describable<T>>- Specified by:
addin interfaceList<T extends Describable<T>>- Overrides:
addin classAbstractList<Descriptor<T extends Describable<T>>>
-
add
@Deprecated public void add(int index, Descriptor<T> element)
Deprecated.As of 1.286. PutExtensionon your descriptor to have it auto-registered, instead of registering a descriptor manually.- Specified by:
addin interfaceList<T extends Describable<T>>- Overrides:
addin classAbstractList<Descriptor<T extends Describable<T>>>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T extends Describable<T>>- Specified by:
removein interfaceList<T extends Describable<T>>- Overrides:
removein classAbstractCollection<Descriptor<T extends Describable<T>>>
-
newInstanceFromRadioList
@CheckForNull public T newInstanceFromRadioList(net.sf.json.JSONObject config) throws Descriptor.FormException
Creates a new instance of aDescribablefrom the structured form submission data posted by a radio button group.- Parameters:
config- Submitted configuration for Radio List- Returns:
- New instance.
nullif none was selected in the radio list or if the value is filtered by aDescriptorVisibilityFilter - Throws:
Descriptor.FormException- Data submission error
-
newInstanceFromRadioList
@CheckForNull public T newInstanceFromRadioList(net.sf.json.JSONObject parent, String name) throws Descriptor.FormException
Creates a new instance of aDescribablefrom the structured form submission data posted by a radio button group.- Parameters:
parent- JSON, which contains the configuration entry for the radio listname- Name of the configuration entry for the radio list- Returns:
- New instance.
nullif none was selected in the radio list or if the value is filtered by aDescriptorVisibilityFilter - Throws:
Descriptor.FormException- Data submission error
-
findByName
@CheckForNull public Descriptor<T> findByName(String id)
Finds a descriptor by theirDescriptor.getId().- Parameters:
id- Descriptor ID- Returns:
- If none is found,
nullis returned.
-
load
public void load(Class<? extends Describable> c)
No-op method used to force the class initialization of the given class. The class initialization in turn is expected to put the descriptor into theDescriptorList.This is necessary to resolve the class initialization order problem. Often a
DescriptorListis defined in the base class, and when it tries to initialize itself by listing up descriptors of known sub-classes, they might not be available in time.- Since:
- 1.162
-
find
@Deprecated @CheckForNull public Descriptor<T> find(String fqcn)
Deprecated.Underspecified what the parameter is.Descriptor.getId()? ADescribableclass name?Finds the descriptor that has the matching fully-qualified class name.
-
-