Package jenkins.widgets
Class WidgetFactory<T extends HasWidgets,W extends Widget>
java.lang.Object
jenkins.widgets.WidgetFactory<T,W>
- Type Parameters:
T
- The type of object to add widgets to.W
- The subtype ofWidget
the factory contributes.
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
BuildHistoryWidget.FactoryImpl
,BuildQueueWidget.ComputerSetFactoryImpl
,BuildQueueWidget.ViewFactoryImpl
,ExecutorsWidget.ComputerFactoryImpl
,ExecutorsWidget.ComputerSetFactoryImpl
,ExecutorsWidget.ViewFactoryImpl
,HistoryWidget.FactoryImpl
,JenkinsWidgetFactory
public abstract class WidgetFactory<T extends HasWidgets,W extends Widget>
extends Object
implements ExtensionPoint
Allows you to add new widgets to various kind of objects whose class implements
HasWidgets
.- Since:
- 2.410
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Collection<W>
Creates widgets for a given object.static <T extends HasWidgets,
W extends Widget>
Iterable<WidgetFactory<T,W>> factoriesFor
(Class<T> type, Class<W> widgetType) type()
The type of object this factory cares about.A supertype of any widgets this factory might produce.
-
Constructor Details
-
WidgetFactory
public WidgetFactory()
-
-
Method Details
-
type
The type of object this factory cares about. Declared separately, rather than by havingcreateFor(T)
do a check-cast, so that method bodies are not loaded until actually needed.- Returns:
- the type of
WidgetFactory
-
widgetType
A supertype of any widgets this factory might produce. Defined so that factories which produce irrelevant widgets need not be consulted. If your implementation was returning multiple disparate kinds of widgets, it is best to split it into two factories.If an API defines an abstract
Widget
subtype, and you are providing a concrete implementation, you may return the API type here to delay class loading.- Returns:
- a bound for the result of
createFor(T)
-
createFor
Creates widgets for a given object. This may be called frequently for the same object, so if your implementation is expensive, do your own caching.- Parameters:
target
- a widgetable object- Returns:
- a possible empty set of widgets (typically either using
Set.of()
).
-
factoriesFor
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static <T extends HasWidgets,W extends Widget> Iterable<WidgetFactory<T,W>> factoriesFor(Class<T> type, Class<W> widgetType)
-