Class DataCountEndedEvent
- All Implemented Interfaces:
Serializable
service event bus
once a count query has returned or thrown, on the thread that issued it.
Fired in reverse listener registration order, so that listeners nest around
the matching DataCountStartedEvent. It is fired whether the query
returned normally or threw, so a listener can clean up its state in one
place.
The event tells how long the query took and, through a count of -1, whether it threw, so a listener that times count
queries needs no state of its own and no listener for the started or failed
event.
- Since:
- 25.3
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionDataCountEndedEvent(UI ui, Component component, boolean filtered, int count) Creates a new event for a count query whose duration was not measured.DataCountEndedEvent(UI ui, Component component, boolean filtered, int count, Duration duration) Creates a new event carrying the measured duration of the count query. -
Method Summary
Modifier and TypeMethodDescriptionintgetCount()Gets the number of items the data provider reported.Gets how long the count query took, measured from just before theDataCountStartedEventwas fired until the query returned or threw.Methods inherited from class com.vaadin.flow.server.data.AbstractDataCountEvent
getComponent, getSource, getUI, isFilteredMethods inherited from class java.util.EventObject
toString
-
Constructor Details
-
DataCountEndedEvent
Creates a new event for a count query whose duration was not measured.The event reports a
zeroduration. UseDataCountEndedEvent(UI, Component, boolean, int, Duration)to create an event with a measured duration.- Parameters:
ui- the UI the counting component belongs to, notnullcomponent- the component whose data is being counted, ornullif it could not be resolvedfiltered- whether a filter was set on the querycount- the number of items the data provider reported, or-1if the query threw, in which case aDataCountFailedEventcarrying the throwable was fired first
-
DataCountEndedEvent
public DataCountEndedEvent(UI ui, Component component, boolean filtered, int count, Duration duration) Creates a new event carrying the measured duration of the count query.- Parameters:
ui- the UI the counting component belongs to, notnullcomponent- the component whose data is being counted, ornullif it could not be resolvedfiltered- whether a filter was set on the querycount- the number of items the data provider reported, or-1if the query threw, in which case aDataCountFailedEventcarrying the throwable was fired firstduration- the time from just before the started event was fired until the query returned or threw, notnull- Since:
- 25.4
-
-
Method Details
-
getCount
public int getCount()Gets the number of items the data provider reported.A value of
-1is how this event reports that the query threw, so a listener can tell a failed query from an empty result without listening forDataCountFailedEvent, which carries the throwable itself.- Returns:
- the count, or
-1if the query threw
-
getDuration
Gets how long the count query took, measured from just before theDataCountStartedEventwas fired until the query returned or threw. It includes the time the listeners of the started and failed events took, but not the time spent on this event.- Returns:
- the duration, never negative
- Since:
- 25.4
-