Example usage for org.springframework.data.domain Slice getNumberOfElements

List of usage examples for org.springframework.data.domain Slice getNumberOfElements

Introduction

In this page you can find the example usage for org.springframework.data.domain Slice getNumberOfElements.

Prototype

int getNumberOfElements();

Source Link

Document

Returns the number of elements currently on this Slice .

Usage

From source file:org.eclipse.hawkbit.repository.jpa.JpaRolloutManagement.java

private void deleteScheduledActions(final JpaRollout rollout, final Slice<JpaAction> scheduledActions) {
    final boolean hasScheduledActions = scheduledActions.getNumberOfElements() > 0;

    if (hasScheduledActions) {
        try {/* w  w  w  .ja v a2 s.c  o  m*/
            final Iterable<JpaAction> iterable = scheduledActions::iterator;
            final List<Long> actionIds = StreamSupport.stream(iterable.spliterator(), false).map(Action::getId)
                    .collect(Collectors.toList());
            actionRepository.deleteByIdIn(actionIds);
            afterCommit.afterCommit(() -> eventPublisher.publishEvent(
                    new RolloutUpdatedEvent(rollout, EventPublisherHolder.getInstance().getApplicationId())));
        } catch (final RuntimeException e) {
            LOGGER.error("Exception during deletion of actions of rollout {}", rollout, e);
        }
    }
}