class AdminChangeLogLevel implements JsonRpcMethod {

  @Override
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    try {
      final Level logLevel = requestContext.getRequiredParameter(0, Level.class);
      final Optional<String[]> optionalLogFilters =
          requestContext.getOptionalParameter(1, String[].class);
      optionalLogFilters.ifPresentOrElse(
          logFilters ->
              Arrays.stream(logFilters).forEach(logFilter -> setLogLevel(logFilter, logLevel)),
          () -> setLogLevel("", logLevel));
      return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
    } catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
    }
  }

}