public ServletLimiterBuilder partitionByUserPrincipal(Function<Principal, String> principalToGroup) {
        return partitionResolver(request -> Optional.ofNullable(request.getUserPrincipal()).map(principalToGroup).orElse(null));
    }
public ServletLimiterBuilder partitionByUserPrincipal ( Function < Principal , String > principalToGroup ) { return partitionResolver ( request -> Optional . ofNullable ( request . getUserPrincipal ( ) ) . map ( principalToGroup ) . orElse ( null ) ) ; }
Partition the limit by {@link Principal}. Percentages of the limit are partitioned to named
groups.  Group membership is derived from the provided mapping function.
@param principalToGroup Mapping function from {@link Principal} to a named group.
@return Chainable builder