public String accepts(@NotNull final String... types) {
        String accept = getHeader("Accept");
        // accept anything when accept is not present
        if (accept == null) {
            return types[0];
        }

        // parse
        String[] acceptTypes = accept.split(" *, *");
        // sort on quality
        Arrays.sort(acceptTypes, ACCEPT_X_COMPARATOR);

        for (String senderAccept : acceptTypes) {
            String[] sAccept = splitMime(senderAccept);

            for (String appAccept : types) {
                String[] aAccept = splitMime(appAccept);

                if (
                        (sAccept[0].equals(aAccept[0]) || "*".equals(sAccept[0]) || "*".equals(aAccept[0])) &&
                        (sAccept[1].equals(aAccept[1]) || "*".equals(sAccept[1]) || "*".equals(aAccept[1]))) {
                    return senderAccept;
                }
            }
        }

        return null;
    }
public String accepts ( @ NotNull final String ... types ) { String accept = getHeader ( "Accept" ) ; if ( accept == null ) { return types [ 0 ] ; } String [ ] acceptTypes = accept . split ( " *, *" ) ; Arrays . sort ( acceptTypes , ACCEPT_X_COMPARATOR ) ; for ( String senderAccept : acceptTypes ) { String [ ] sAccept = splitMime ( senderAccept ) ; for ( String appAccept : types ) { String [ ] aAccept = splitMime ( appAccept ) ; if ( ( sAccept [ 0 ] . equals ( aAccept [ 0 ] ) || "*" . equals ( sAccept [ 0 ] ) || "*" . equals ( aAccept [ 0 ] ) ) && ( sAccept [ 1 ] . equals ( aAccept [ 1 ] ) || "*" . equals ( sAccept [ 1 ] ) || "*" . equals ( aAccept [ 1 ] ) ) ) { return senderAccept ; } } } return null ; }
Check if the given type(s) is acceptable, returning the best match when true, otherwise null, in which
case you should respond with 406 "Not Acceptable".

The type value must be a single mime type string such as "application/json" and is validated by checking
if the request string starts with it.