/** * Check if a valid match for given content type formated string (<code>toMatch</code>) exists in given list. * Therefore the given content type formated string (<code>toMatch</code>) is converted into a {@link ContentType} * with a simple {@link #create(String)} call (during which an exception can occur). * * For more detail in general see {@link #hasMatch(List)} and for what a valid match is see {@link #match(List)}. * * @param toMatch content type formated string (<code>toMatch</code>) for which is checked if a match exists in given * list * @param matchExamples list of {@link ContentType}s which are matches against content type formated string * (<code>toMatch</code>) * @return <code>true</code> if a matching content type was found in given list * or <code>false</code> if none matching content type match was found */ public static boolean match(final String toMatch, final ContentType... matchExamples) { ContentType toMatchContentType = ContentType.create(toMatch); return toMatchContentType.hasMatch(Arrays.asList(matchExamples)); } }
/** * Check if a valid match for given content type formated string (<code>toMatch</code>) exists in given list. * Therefore the given content type formated string (<code>toMatch</code>) is converted into a {@link ContentType} * with a simple {@link #create(String)} call (during which an exception can occur). * * For more detail in general see {@link #hasMatch(List)} and for what a valid match is see {@link #match(List)}. * * @param toMatch content type formated string (<code>toMatch</code>) for which is checked if a match exists in given * list * @param matchExamples list of {@link ContentType}s which are matches against content type formated string * (<code>toMatch</code>) * @return <code>true</code> if a matching content type was found in given list * or <code>false</code> if none matching content type match was found */ public static boolean match(final String toMatch, final ContentType... matchExamples) { ContentType toMatchContentType = ContentType.create(toMatch); return toMatchContentType.hasMatch(Arrays.asList(matchExamples)); } }
/** * Check if a valid match for given content type formated string (<code>toMatch</code>) exists in given list. * Therefore the given content type formated string (<code>toMatch</code>) is converted into a {@link ContentType} * with a simple {@link #create(String)} call (during which an exception can occur). * * For more detail in general see {@link #hasMatch(List)} and for what a valid match is see {@link #match(List)}. * * @param toMatch content type formated string (<code>toMatch</code>) for which is checked if a match exists in given * list * @param matchExamples list of {@link ContentType}s which are matches against content type formated string * (<code>toMatch</code>) * @return <code>true</code> if a matching content type was found in given list * or <code>false</code> if none matching content type match was found */ public static boolean match(final String toMatch, final ContentType... matchExamples) { ContentType toMatchContentType = ContentType.create(toMatch); return toMatchContentType.hasMatch(Arrays.asList(matchExamples)); } }
/** * Checks if the given list of {@link ContentType}s contains a matching {@link ContentType} for the given * <code>contentType</code> parameter. * @param contentType for which a matching content type is searched * @param allowedContentTypes list against which is checked for possible matching {@link ContentType}s * @return <code>true</code> if a matching content type is in given list, otherwise <code>false</code> */ private static boolean hasMatchingContentType(final ContentType contentType, final List<ContentType> allowedContentTypes) { final ContentType requested = contentType.receiveWithCharsetParameter(ContentNegotiator.DEFAULT_CHARSET); if (requested.getODataFormat() == ODataFormat.CUSTOM || requested.getODataFormat() == ODataFormat.MIME) { return requested.hasCompatible(allowedContentTypes); } return requested.hasMatch(allowedContentTypes); }
/** * Checks if the given list of {@link ContentType}s contains a matching {@link ContentType} for the given * <code>contentType</code> parameter. * @param contentType for which a matching content type is searched * @param allowedContentTypes list against which is checked for possible matching {@link ContentType}s * @return <code>true</code> if a matching content type is in given list, otherwise <code>false</code> */ private static boolean hasMatchingContentType(final ContentType contentType, final List<ContentType> allowedContentTypes) { final ContentType requested = contentType.receiveWithCharsetParameter(ContentNegotiator.DEFAULT_CHARSET); if (requested.getODataFormat() == ODataFormat.CUSTOM || requested.getODataFormat() == ODataFormat.MIME) { return requested.hasCompatible(allowedContentTypes); } return requested.hasMatch(allowedContentTypes); }
/** * Checks if the given list of {@link ContentType}s contains a matching {@link ContentType} for the given * <code>contentType</code> parameter. * @param contentType for which a matching content type is searched * @param allowedContentTypes list against which is checked for possible matching {@link ContentType}s * @return <code>true</code> if a matching content type is in given list, otherwise <code>false</code> */ private static boolean hasMatchingContentType(final ContentType contentType, final List<ContentType> allowedContentTypes) { final ContentType requested = contentType.receiveWithCharsetParameter(ContentNegotiator.DEFAULT_CHARSET); if (requested.getODataFormat() == ODataFormat.CUSTOM || requested.getODataFormat() == ODataFormat.MIME) { return requested.hasCompatible(allowedContentTypes); } return requested.hasMatch(allowedContentTypes); }