1030 - Change to DefaultEventStream
@@ -86,12 +86,13 @@ public class DefaultEventsStream implements EventsStream {
public DefaultEventsStream(final ImmutableAccountData account,
final SubscriptionBaseBundle bundle,
final Collection<BlockingState> blockingStates,
+ final Collection<BlockingState> blockingStatesWithDeletedEvents,
final BlockingChecker blockingChecker,
@Nullable final SubscriptionBase baseSubscription,
final SubscriptionBase subscription,
final Collection<SubscriptionBase> allSubscriptionsForBundle,
@Nullable final Integer defaultBillCycleDayLocal,
- final InternalTenantContext contextWithValidAccountRecordId, final DateTime utcNow, final boolean includeDeletedEvents) {
+ final InternalTenantContext contextWithValidAccountRecordId, final DateTime utcNow) {
sanityChecks(account, bundle, baseSubscription, subscription);
this.account = account;
this.bundle = bundle;
@@ -104,19 +105,26 @@ public class DefaultEventsStream implements EventsStream {
this.utcNow = utcNow;
this.utcToday = contextWithValidAccountRecordId.toLocalDate(utcNow);
- this.includeDeletedEvents = includeDeletedEvents;
-
- if (includeDeletedEvents) {
- this.blockingStatesWithDeletedEvents = blockingStates;
- this.blockingStates = blockingStates.stream().filter(state -> state.isActive()).collect(Collectors.toList());
- } else {
this.blockingStates = blockingStates;
- this.blockingStatesWithDeletedEvents = Collections.emptyList();
- }
+ this.blockingStatesWithDeletedEvents = blockingStatesWithDeletedEvents;
+ this.includeDeletedEvents = !blockingStatesWithDeletedEvents.isEmpty();
setup();
}
+ public DefaultEventsStream(final ImmutableAccountData account,
+ final SubscriptionBaseBundle bundle,
+ final Collection<BlockingState> blockingStates,
+ final BlockingChecker blockingChecker,
+ @Nullable final SubscriptionBase baseSubscription,
+ final SubscriptionBase subscription,
+ final Collection<SubscriptionBase> allSubscriptionsForBundle,
+ @Nullable final Integer defaultBillCycleDayLocal,
+ final InternalTenantContext contextWithValidAccountRecordId, final DateTime utcNow) {
+ this(account, bundle, blockingStates, Collections.emptyList(), blockingChecker, baseSubscription, subscription, allSubscriptionsForBundle, defaultBillCycleDayLocal, contextWithValidAccountRecordId, utcNow);
+ }
+
+
private void sanityChecks(@Nullable final ImmutableAccountData account,
@Nullable final SubscriptionBaseBundle bundle,
@Nullable final SubscriptionBase baseSubscription,
@@ -237,6 +245,11 @@ public class DefaultEventsStream implements EventsStream {
return aggregator.isBlockChange();
}
+ @Override
+ public boolean getIncludeDeletedEvents() {
+ return this.includeDeletedEvents;
+ }
+
@Override
public boolean isBlockEntitlement(final DateTime effectiveDate) {
Preconditions.checkState(effectiveDate != null);
@@ -250,7 +263,7 @@ public class DefaultEventsStream implements EventsStream {
}
@Override
- public Collection<BlockingState> getBlockingStates() {
+ public Collection<BlockingState> getBlockingStates(final boolean includeDeletedEvents) {
return includeDeletedEvents ? blockingStatesWithDeletedEvents : blockingStates;
}
