Class EventListenerParameters
- java.lang.Object
-
- org.apache.commons.configuration2.builder.EventListenerParameters
-
- All Implemented Interfaces:
BuilderParameters
,EventListenerProvider
public class EventListenerParameters extends java.lang.Object implements BuilderParameters, EventListenerProvider
A specialized parameters implementation for
BasicConfigurationBuilder
which allows for a convenient event listener initialization.This class offers a fluent interface for registering event listeners. A fully initialized instance can be passed to the
BasicConfigurationBuilder.configure(BuilderParameters...)
method. All event listeners which have been registered at the instance are then copied over to the configuration builder.The code fragment below shows a typical usage scenario:
BasicConfigurationBuilder<Configuration> builder = new BasicConfigurationBuilder<Configuration>( PropertiesConfiguration.class) .configure(new EventListenerParameters().addEventListener( ConfigurationEvent.ANY, myListener));
In order to support a configuration builder's
configure()
method, this class implements theBuilderParameters
interface. However, this is just a dummy implementation; no parameters are propagated to the builder.- Since:
- 2.0
- Version:
- $Id: EventListenerParameters.java 1679772 2015-05-16 17:41:17Z oheger $
-
-
Field Summary
-
Fields inherited from interface org.apache.commons.configuration2.builder.BuilderParameters
RESERVED_PARAMETER_PREFIX
-
-
Constructor Summary
Constructors Constructor Description EventListenerParameters()
Creates a new instance ofEventListenerParameters
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Event>
EventListenerParametersaddEventListener(EventListenerRegistrationData<T> registrationData)
Adds the specifiedEventListenerRegistrationData
instance to this object.<T extends Event>
EventListenerParametersaddEventListener(EventType<T> eventType, EventListener<? super T> listener)
Adds an event listener of the specified event type to this object.EventListenerList
getListeners()
Returns anEventListenerList
object with information about event listener registrations.java.util.Map<java.lang.String,java.lang.Object>
getParameters()
Returns a map with all parameters defined by this objects.
-
-
-
Method Detail
-
addEventListener
public <T extends Event> EventListenerParameters addEventListener(EventType<T> eventType, EventListener<? super T> listener)
Adds an event listener of the specified event type to this object.- Type Parameters:
T
- the event type- Parameters:
eventType
- the event type objectlistener
- the event listener- Returns:
- a reference to this object for method chaining
-
addEventListener
public <T extends Event> EventListenerParameters addEventListener(EventListenerRegistrationData<T> registrationData)
Adds the specifiedEventListenerRegistrationData
instance to this object.- Type Parameters:
T
- the event type of the contained event listener- Parameters:
registrationData
- the registration object to be added- Returns:
- a reference to this object for method chaining
-
getParameters
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Returns a map with all parameters defined by this objects. The keys of the map correspond to concrete properties supported by theConfiguration
implementation class the builder produces. The values are the corresponding property values. The return value must not be null. This implementation returns an empty map.- Specified by:
getParameters
in interfaceBuilderParameters
- Returns:
- a map with builder parameters
-
getListeners
public EventListenerList getListeners()
Description copied from interface:EventListenerProvider
Returns anEventListenerList
object with information about event listener registrations. All listeners contained in this object are added to the processingConfigurationBuilder
.- Specified by:
getListeners
in interfaceEventListenerProvider
- Returns:
- the
EventListenerList
with event listener registrations (must not be null)
-
-