@AfterReturning( pointcut = "aspects.pointcuts.PointcutDefinitions.allControllerMethods()", returning = "returnedValue") public void afterReturning(ResponseSerializer returnedValue) { if (isCorrectResult(returnedValue)) { if (returnedValue.getResult() instanceof Collection) { returnedValue.setStatus( ((Collection) returnedValue.getResult()).isEmpty() ? ResponseStatus.ZERO_RESULTS : ResponseStatus.OK); } else { returnedValue.setStatus(ResponseStatus.OK); } } }
private boolean isCorrectResult(ResponseSerializer rs) { return !resultErrorStatuses.contains(rs.getStatus()); }