Interface SubscriptionStatusHandler<SWI extends SubscriptionWithItems>
- All Known Implementing Classes:
ActiveSubscriptionStatusHandler,CanceledSubscriptionStatusHandler,FulfillmentInProcessSubscriptionStatusHandler,PausedSubscriptionStatusHandler,PendingCancellationSubscriptionStatusHandler
public interface SubscriptionStatusHandler<SWI extends SubscriptionWithItems>
A handler that handles a
Subscription's status change, e.g. validates if the
UpdateSubscriptionStatusRequest.getRequestedStatus() can be applied to the
Subscription with particular status.- Author:
- Dima Myroniuk (dmyroniuk)
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(UpdateSubscriptionStatusRequest request, SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if this handler can handle the status change.default Subscriptionprocess(UpdateSubscriptionStatusRequest request, SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes theSubscriptionstatus change if it is valid.voidvalidateStatusChange(UpdateSubscriptionStatusRequest request, SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that theUpdateSubscriptionStatusRequest.getRequestedStatus()is a valid next status of theSubscription.
-
Method Details
-
canHandle
boolean canHandle(UpdateSubscriptionStatusRequest request, SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if this handler can handle the status change.- Parameters:
request- the request to modify a subscription's statusswi- theSubscriptionWithItemscontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if this handler can handle the status change, otherwise false
-
validateStatusChange
void validateStatusChange(UpdateSubscriptionStatusRequest request, SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that theUpdateSubscriptionStatusRequest.getRequestedStatus()is a valid next status of theSubscription.- Parameters:
request- the request to modify a subscription's statusswi- theSubscriptionWithItemsto validatecontextInfo- context information surrounding sandboxing and multitenant state- Throws:
InvalidSubscriptionStatusChangeRequestException- if the status change is invalid
-
process
default Subscription process(UpdateSubscriptionStatusRequest request, SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes theSubscriptionstatus change if it is valid.- Parameters:
request- the request to modify a subscription's statusswi- theSubscriptionWithItemsto process the status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the
Subscriptionwith updated status
-