Package com.norconex.commons.lang.config
Interface Configurable<T>
- Type Parameters:
T- The configuration class type
public interface Configurable<T>
The implementing class can be configured via the object returned
by
getConfiguration().
Provides a consistent way to obtain a file configuration dynamically.
Could be useful for object mapping, for instance.- Since:
- 3.0.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R extends Configurable<T>>
RConvenience method to facilitate configuring this instance in method chaining.Gets the configuration for a configurable object.
-
Field Details
-
PROPERTY
Practical constant for the string representation of the "configuration" property.- See Also:
-
-
Method Details
-
getConfiguration
T getConfiguration()Gets the configuration for a configurable object. Nevernull.- Returns:
- configuration
-
configure
@SafeVarargs static <T,R extends Configurable<T>> R configure(R configurable, Consumer<T>... configurers) Convenience method to facilitate configuring this instance in method chaining. E.g.
var myClass = Configurable.configure( new MyConfigurableClass(), cfg -> cfg.setSomeValue("my value"));You can supply multiple consumers and they'll all be executed in the order provided. This is an alternative to using lambda
Consumer.andThen(Consumer)without the need for casting.- Parameters:
configurable- the configurable objectconfigurers- one or more object configuration consumers (not invoked ifnullor if the configuration isnull)- Returns:
- this instance
-