Source:
<code>public Optional<TokenCredentials> extract(final WebContext context) { final CasLogoutHandler logoutHandler = configuration.findLogoutHandler(); if (isTokenRequest(context)) { <START> final String ticket = context.getRequestParameter(CasConfiguration.TICKET_PARAMETER).orElse(null); <END> if (logoutHandler != null) { logoutHandler.recordSession(context, ticket); } final TokenCredentials casCredentials = new TokenCredentials(ticket); logger.debug("casCredentials: {}", casCredentials); return Optional.of(casCredentials); } else if (isBackLogoutRequest(context)) { final String logoutMessage = context.getRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER).orElse(null); logger.trace("Logout request:\n{}", logoutMessage); final String ticket = CommonHelper.substringBetween(logoutMessage, CasConfiguration.SESSION_INDEX_TAG + ">", "</"); if (CommonUtils.isNotBlank(ticket) && logoutHandler != null) { logoutHandler.destroySessionBack(context, ticket); } logger.debug("back logout request: no credential returned"); throw HttpAction.noContent(context); } else if (isFrontLogoutRequest(context)) { final String logoutMessage = uncompressLogoutMessage( context.getRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER).orElse(null) ); logger.trace("Logout request:\n{}", logoutMessage); final String ticket = CommonHelper.substringBetween(logoutMessage, CasConfiguration.SESSION_INDEX_TAG + ">", "</"); if (CommonUtils.isNotBlank(ticket) && logoutHandler != null) { logoutHandler.destroySessionFront(context, ticket); } logger.debug("front logout request: no credential returned"); computeRedirectionToServerIfNecessary(context); } return Optional.empty(); }</code><technical_language>decide do if present instead of passing a nullable object TokenCredentials? accept optional accept a nullable value</technical_language>

Target:
public Optional<TokenCredentials> extract(final WebContext context) { final CasLogoutHandler logoutHandler = configuration.findLogoutHandler(); if (isTokenRequest(context)) { final String ticket = context.getRequestParameter(CasConfiguration.TICKET_PARAMETER).get(); if (logoutHandler != null) { logoutHandler.recordSession(context, ticket); } final TokenCredentials casCredentials = new TokenCredentials(ticket); logger.debug("casCredentials: {}", casCredentials); return Optional.of(casCredentials); } else if (isBackLogoutRequest(context)) { final String logoutMessage = context.getRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER).get(); logger.trace("Logout request:\n{}", logoutMessage); final String ticket = CommonHelper.substringBetween(logoutMessage, CasConfiguration.SESSION_INDEX_TAG + ">", "</"); if (CommonUtils.isNotBlank(ticket) && logoutHandler != null) { logoutHandler.destroySessionBack(context, ticket); } logger.debug("back logout request: no credential returned"); throw HttpAction.noContent(context); } else if (isFrontLogoutRequest(context)) { final String logoutMessage = uncompressLogoutMessage( context.getRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER).get() ); logger.trace("Logout request:\n{}", logoutMessage); final String ticket = CommonHelper.substringBetween(logoutMessage, CasConfiguration.SESSION_INDEX_TAG + ">", "</"); if (CommonUtils.isNotBlank(ticket) && logoutHandler != null) { logoutHandler.destroySessionFront(context, ticket); } logger.debug("front logout request: no credential returned"); computeRedirectionToServerIfNecessary(context); } return Optional.empty(); }