Class AlternativeUiTextProvider
- java.lang.Object
-
- hudson.util.AlternativeUiTextProvider
-
- All Implemented Interfaces:
ExtensionPoint
public abstract class AlternativeUiTextProvider extends Object implements ExtensionPoint
Provides the alternative text to be rendered in the UI.In a few limited places in Jenkins, we want to provide an ability for plugins to replace the text to be shown in the UI. Since each such case is rather trivial and can't justify its own extension point, we consolidate all such use cases into a single extension point.
Each such overridable UI text can have a context, which represents some information that enables the
AlternativeUiTextProviderto make intelligent decision. This is normally some kind of a model object, such asAbstractProject.To define a new UI text that can be overridable by
AlternativeUiTextProvider, define a constant ofAlternativeUiTextProvider.Message(parameterized with the context object type), then callget(Message, Object)to obtain a text.To define an implementation that overrides text, define a subtype and put @
Extensionon it. SeeAbstractProject.getBuildNowText()as an example.- Since:
- 1.401
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAlternativeUiTextProvider.Message<T>Each instance of this class represents a text that can be replaced byAlternativeUiTextProvider.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description AlternativeUiTextProvider()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<AlternativeUiTextProvider>all()All the registered extension point instances.static <T> Stringget(AlternativeUiTextProvider.Message<T> text, T context)Consults all the existingAlternativeUiTextProviderand return an override, if any, or null.static <T> Stringget(AlternativeUiTextProvider.Message<T> text, T context, String defaultValue)abstract <T> StringgetText(AlternativeUiTextProvider.Message<T> text, T context)Provides an opportunity to override the message text.
-
-
-
Method Detail
-
getText
public abstract <T> String getText(AlternativeUiTextProvider.Message<T> text, T context)
Provides an opportunity to override the message text.- Parameters:
text- Always non-null. Caller should pass in aAlternativeUiTextProvider.Messageconstant that represents the text that we are being considered.context- Context object. See class javadoc above.
-
all
public static ExtensionList<AlternativeUiTextProvider> all()
All the registered extension point instances.
-
get
public static <T> String get(AlternativeUiTextProvider.Message<T> text, T context, String defaultValue)
-
get
public static <T> String get(AlternativeUiTextProvider.Message<T> text, T context)
Consults all the existingAlternativeUiTextProviderand return an override, if any, or null.
-
-