Source:
<code>public void validate(final TokenCredentials credentials, final WebContext context) { init(); final String ticket = credentials.getToken(); try { final String finalCallbackUrl = callbackUrlResolver.compute(callbackUrl, clientName, context); final Assertion assertion = configuration.retrieveTicketValidator(context).validate(ticket, finalCallbackUrl); final AttributePrincipal principal = assertion.getPrincipal(); logger.debug("principal: {}", principal); final String id = principal.getName(); final Map<String, Object> newAttributes = new HashMap<>(); final Map<String, Object> attributes = principal.getAttributes(); if (attributes != null) { for (final Map.Entry<String, Object> entry : attributes.entrySet()){ final String key = entry.getKey(); final Object value = entry.getValue(); final Object restored = ProfileHelper.getInternalAttributeHandler().restore(value); newAttributes.put(key, restored); } } final CommonProfile profile; if (configuration.getProxyReceptor() != null) { profile = getProfileDefinition().newProfile(principal, configuration.getProxyReceptor()); profile.setId(ProfileHelper.sanitizeIdentifier(profile, id)); getProfileDefinition().convertAndAdd(profile, newAttributes); } else { profile = ProfileHelper.restoreOrBuildProfile(getProfileDefinition(), id, newAttributes, principal, <START> configuration.getProxyReceptor()).orElse(null); <END> } logger.debug("profile returned by CAS: {}", profile); credentials.setUserProfile(profile); } catch (final TicketValidationException e) { String message = "cannot validate CAS ticket: " + ticket; throw new TechnicalException(message, e); } }</code><technical_language>reason advantage of optional continue instead of transforming a nullable value</technical_language>

Target:
public void validate(final TokenCredentials credentials, final WebContext context) { init(); final String ticket = credentials.getToken(); try { final String finalCallbackUrl = callbackUrlResolver.compute(callbackUrl, clientName, context); final Assertion assertion = configuration.retrieveTicketValidator(context).validate(ticket, finalCallbackUrl); final AttributePrincipal principal = assertion.getPrincipal(); logger.debug("principal: {}", principal); final String id = principal.getName(); final Map<String, Object> newAttributes = new HashMap<>(); final Map<String, Object> attributes = principal.getAttributes(); if (attributes != null) { for (final Map.Entry<String, Object> entry : attributes.entrySet()){ final String key = entry.getKey(); final Object value = entry.getValue(); final Object restored = ProfileHelper.getInternalAttributeHandler().restore(value); newAttributes.put(key, restored); } } final CommonProfile profile; if (configuration.getProxyReceptor() != null) { profile = getProfileDefinition().newProfile(principal, configuration.getProxyReceptor()); profile.setId(ProfileHelper.sanitizeIdentifier(profile, id)); getProfileDefinition().convertAndAdd(profile, newAttributes); } else { profile = ProfileHelper.restoreOrBuildProfile(getProfileDefinition(), id, newAttributes, principal, configuration.getProxyReceptor()).get(); } logger.debug("profile returned by CAS: {}", profile); credentials.setUserProfile(profile); } catch (final TicketValidationException e) { String message = "cannot validate CAS ticket: " + ticket; throw new TechnicalException(message, e); } }