Skip to content

Commit

Permalink
Move methods containing response data to NotificationResponseService
Browse files Browse the repository at this point in the history
  • Loading branch information
agrancaric committed Mar 30, 2022
1 parent 360db78 commit 21a4a1e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,19 @@ public interface BaseNotificationResponseService<T> {
/**
* Returns response with {@link net.croz.nrich.notification.api.model.Notification} instance.
*
* @param data data to include in response
* @param actionName name of the action for which to resolve notification
* @param additionalNotificationData additional notification data to add to notification
* @param <D> type of data
* @return response with notification
*/
<D> T responseWithNotificationActionResolvedFromRequest(D data, AdditionalNotificationData additionalNotificationData);
T responseWithNotification(String actionName, AdditionalNotificationData additionalNotificationData);

/**
* Returns response with {@link net.croz.nrich.notification.api.model.Notification} instance.
*
* @param data data to include in response
* @param actionName name of the action for which to resolve notification
* @param additionalNotificationData additional notification data to add to notification
* @param <D> type of data
* @return response with notification
*/
<D> T responseWithNotification(D data, String actionName, AdditionalNotificationData additionalNotificationData);
T responseWithNotificationActionResolvedFromRequest(AdditionalNotificationData additionalNotificationData);

NotificationResolverService notificationResolverService();

Expand All @@ -78,19 +74,11 @@ default T responseWithExceptionNotification(Throwable throwable, Object... addit
return responseWithExceptionNotification(throwable, AdditionalNotificationData.empty(), additionalMessageArgumentList);
}

default <D> T responseWithNotificationActionResolvedFromRequest(D data) {
return responseWithNotificationActionResolvedFromRequest(data, AdditionalNotificationData.empty());
}

default <D> T responseWithNotification(D data, String actionName) {
return responseWithNotification(data, actionName, AdditionalNotificationData.empty());
}

default T responseWithNotificationActionResolvedFromRequest() {
return responseWithNotificationActionResolvedFromRequest(null, AdditionalNotificationData.empty());
return responseWithNotificationActionResolvedFromRequest(AdditionalNotificationData.empty());
}

default T responseWithNotification(String actionName) {
return responseWithNotification(null, actionName, AdditionalNotificationData.empty());
return responseWithNotification(actionName, AdditionalNotificationData.empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@

public interface NotificationResponseService extends BaseNotificationResponseService<NotificationResponse> {

@Override
/**
* Returns response with {@link net.croz.nrich.notification.api.model.Notification} instance.
*
* @param data data to include in response
* @param additionalNotificationData additional notification data to add to notification
* @param <D> type of data
* @return response with notification
*/
<D> NotificationDataResponse<D> responseWithNotificationActionResolvedFromRequest(D data, AdditionalNotificationData additionalNotificationData);

@Override
/**
* Returns response with {@link net.croz.nrich.notification.api.model.Notification} instance.
*
* @param data data to include in response
* @param actionName name of the action for which to resolve notification
* @param additionalNotificationData additional notification data to add to notification
* @param <D> type of data
* @return response with notification
*/
<D> NotificationDataResponse<D> responseWithNotification(D data, String actionName, AdditionalNotificationData additionalNotificationData);

@Override
default <D> NotificationDataResponse<D> responseWithNotificationActionResolvedFromRequest(D data) {
return responseWithNotificationActionResolvedFromRequest(data, AdditionalNotificationData.empty());
}

@Override
default <D> NotificationDataResponse<D> responseWithNotification(D data, String actionName) {
return responseWithNotification(data, actionName, AdditionalNotificationData.empty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ public NotificationResponse responseWithExceptionNotification(Throwable throwabl
return new NotificationResponse(notification);
}

@Override
public NotificationResponse responseWithNotificationActionResolvedFromRequest(AdditionalNotificationData additionalNotificationData) {
String actionName = extractActionNameFromCurrentRequest();

return responseWithNotification(actionName, additionalNotificationData);
}

@Override
public NotificationResponse responseWithNotification(String actionName, AdditionalNotificationData additionalNotificationData) {
Notification notification = notificationResolverService.createNotificationForAction(actionName, additionalNotificationData);

return new NotificationResponse(notification);
}

@Override
public <D> NotificationDataResponse<D> responseWithNotificationActionResolvedFromRequest(D data, AdditionalNotificationData additionalNotificationData) {
String actionName = extractActionNameFromCurrentRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public Object responseWithExceptionNotification(Throwable throwable, AdditionalN
}

@Override
public <D> Object responseWithNotificationActionResolvedFromRequest(D data, AdditionalNotificationData additionalNotificationData) {
public Object responseWithNotification(String actionName, AdditionalNotificationData additionalNotificationData) {
return null;
}

@Override
public <D> Object responseWithNotification(D data, String actionName, AdditionalNotificationData additionalNotificationData) {
public Object responseWithNotificationActionResolvedFromRequest(AdditionalNotificationData additionalNotificationData) {
return null;
}

Expand Down

0 comments on commit 21a4a1e

Please sign in to comment.