Skip to content

Commit

Permalink
refactor: expose the items count API to components (#9257)
Browse files Browse the repository at this point in the history
Exposes DataCommunicator::getDataProviderSize to the components, in order to get the items count taking into account the countCallback, if it has been set previously.

Related-to: vaadin/flow-components#282
  • Loading branch information
mshabarov authored Oct 28, 2020
1 parent a044f5d commit 9ee754f
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,18 @@ public void setFetchEnabled(boolean fetchEnabled) {
}

/**
* Getter method for determining the item count of the data. Can be
* overridden by a subclass that uses a specific type of DataProvider and/or
* query.
* Getter method for determining the item count of the data.
* <p>
* This method should be used only with defined size, i.e. when
* {@link #isDefinedSize()} returns {@code code}.
* <p>
* Can be overridden by a subclass that uses a specific type of DataProvider
* and/or query.
*
* @return the size of data provider with current filter
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected int getDataProviderSize() {
public int getDataProviderSize() {
assert definedSize : "This method should never be called when using undefined size";
if (countCallback != null) {
return countCallback.count(new Query(getFilter()));
Expand Down

0 comments on commit 9ee754f

Please sign in to comment.