Package swingtree.api
Interface Configurator<T>
- Type Parameters:
T
- the type of the configuration object
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A configurator is a functional interface that takes a configuration object and
returns a transformed configuration object.
Typically, this configuration object is an immutable builder type.
It is commonly used to configure table models or cell renderer,
check out the following methods for these additional usage sites:
UIForTable.withModel(Configurator)
UIForTable.withModel(Class, Configurator)
UIForTable.withCells(Configurator)
UIForList.withCells(Configurator)
UIForCombo.withCells(Configurator)
Configurators are also heavily used for defining the style
of components through the UIForAnySwing.withStyle(Styler)
method or when writing a custom StyleSheet
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Configurator
<T> andThen
(Configurator<T> after) Returns a new configurator that first configures the given configuration object and then configures the result of this configuration through the provided configurator.Configures the given configuration object and returns the transformed configuration object.static <T> Configurator
<T> none()
Returns a configurator that does nothing, i.e.
-
Method Details
-
none
Returns a configurator that does nothing, i.e. it returns the "null" object or "no-op" object for this interface. It is recommended to use the returned instance instead of null to avoid null pointer exceptions.- Type Parameters:
T
- The type of the configuration object.- Returns:
- A configurator that does nothing.
-
configure
Configures the given configuration object and returns the transformed configuration object.
Note that this method deliberately requires the handling of checked exceptions at its invocation sites because there may be any number of implementations hiding behind this interface and so it is unwise to assume that all of them will be able to execute gracefully without throwing exceptions.- Parameters:
config
- The configuration object, typically an immutable builder type which uses method chaining to for defining its properties.- Returns:
- The fully transformed/updated configuration object.
- Throws:
Exception
- If the configuration encounters errors in the execution of its implementations.
-
andThen
Returns a new configurator that first configures the given configuration object and then configures the result of this configuration through the provided configurator.- Parameters:
after
- The configurator that should be applied after this configurator.- Returns:
- A new configurator that first configures the given configuration object and then configures the result of this configuration.
-