hudson.util
Class DescriptorList<T extends Describable<T>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<Descriptor<T>>
          extended by 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 of Descriptors.

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 DescriptorList is owned by pre-1.286 plugins where this class doesn't know 'T'. In this mode, legacy is non-null but type is null.

The other mode is the new mode, where the Descriptors are actually stored in ExtensionList (see Jenkins.getDescriptorList(Class)) and this class acts as a view to it. This enables bi-directional interoperability — both descriptors registred automatically and descriptors registered manually are visible from both DescriptorList and ExtensionList. In this mode, legacy is null but type is 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
DescriptorList(Class<T> type)
          Creates a DescriptorList backed by ExtensionList.
DescriptorList(Descriptor<T>... descriptors)
          Deprecated. As of 1.286. Use DescriptorList(Class) instead.
 
Method Summary
 boolean add(Descriptor<T> d)
          Deprecated. As of 1.286. Put Extension on your descriptor to have it auto-registered, instead of registering a descriptor manually.
 void add(int index, Descriptor<T> element)
          Deprecated. As of 1.286. Put Extension on your descriptor to have it auto-registered, instead of registering a descriptor manually.
 Descriptor<T> find(String fqcn)
          Finds the descriptor that has the matching fully-qualified class name.
 Descriptor<T> findByName(String id)
          Finds a descriptor by their Descriptor.getId().
 Descriptor<T> get(int index)
           
 Iterator<Descriptor<T>> iterator()
           
 void load(Class<? extends Describable> c)
          No-op method used to force the class initialization of the given class.
 T newInstanceFromRadioList(net.sf.json.JSONObject config)
          Creates a new instance of a Describable from the structured form submission data posted by a radio button group.
 T newInstanceFromRadioList(net.sf.json.JSONObject parent, String name)
           
 boolean remove(Object o)
           
 int size()
           
 
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.List
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

DescriptorList

public DescriptorList(Descriptor<T>... descriptors)
Deprecated. As of 1.286. Use DescriptorList(Class) instead.

This will create a legacy DescriptorList that is disconnected from ExtensionList.


DescriptorList

public DescriptorList(Class<T> type)
Creates a DescriptorList backed by ExtensionList.

Method Detail

get

public Descriptor<T> get(int index)
Specified by:
get in interface List<Descriptor<T extends Describable<T>>>
Specified by:
get in class AbstractList<Descriptor<T extends Describable<T>>>

size

public int size()
Specified by:
size in interface Collection<Descriptor<T extends Describable<T>>>
Specified by:
size in interface List<Descriptor<T extends Describable<T>>>
Specified by:
size in class AbstractCollection<Descriptor<T extends Describable<T>>>

iterator

public Iterator<Descriptor<T>> iterator()
Specified by:
iterator in interface Iterable<Descriptor<T extends Describable<T>>>
Specified by:
iterator in interface Collection<Descriptor<T extends Describable<T>>>
Specified by:
iterator in interface List<Descriptor<T extends Describable<T>>>
Overrides:
iterator in class AbstractList<Descriptor<T extends Describable<T>>>

add

public boolean add(Descriptor<T> d)
Deprecated. As of 1.286. Put Extension on your descriptor to have it auto-registered, instead of registering a descriptor manually.

Specified by:
add in interface Collection<Descriptor<T extends Describable<T>>>
Specified by:
add in interface List<Descriptor<T extends Describable<T>>>
Overrides:
add in class AbstractList<Descriptor<T extends Describable<T>>>

add

public void add(int index,
                Descriptor<T> element)
Deprecated. As of 1.286. Put Extension on your descriptor to have it auto-registered, instead of registering a descriptor manually.

Specified by:
add in interface List<Descriptor<T extends Describable<T>>>
Overrides:
add in class AbstractList<Descriptor<T extends Describable<T>>>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<Descriptor<T extends Describable<T>>>
Specified by:
remove in interface List<Descriptor<T extends Describable<T>>>
Overrides:
remove in class AbstractCollection<Descriptor<T extends Describable<T>>>

newInstanceFromRadioList

public T newInstanceFromRadioList(net.sf.json.JSONObject config)
                                                  throws Descriptor.FormException
Creates a new instance of a Describable from the structured form submission data posted by a radio button group.

Throws:
Descriptor.FormException

newInstanceFromRadioList

public T newInstanceFromRadioList(net.sf.json.JSONObject parent,
                                  String name)
                                                  throws Descriptor.FormException
Throws:
Descriptor.FormException

findByName

public Descriptor<T> findByName(String id)
Finds a descriptor by their Descriptor.getId(). If none is found, null is 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 the DescriptorList.

This is necessary to resolve the class initialization order problem. Often a DescriptorList is 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

public Descriptor<T> find(String fqcn)
Finds the descriptor that has the matching fully-qualified class name.



Copyright © 2004-2013. All Rights Reserved.