/** * Given: * * <pre> * text/html, application/xhtml; {@literal *}/{@literal *} * </pre> * * <pre> * matches(text/html) // true through text/html * matches(application/json) // true through {@literal *}/{@literal *} * </pre> * * @param candidate A candidate media type. Required. * @return True if the matcher matches the given media type. */ public boolean matches(final MediaType candidate) { return doFirst(ImmutableList.of(candidate)).isPresent(); }
/** * Given: * * <pre> * text/html, application/xhtml; {@literal *}/{@literal *} * </pre> * * <pre> * matches(text/html) // true through text/html * matches(application/json) // true through {@literal *}/{@literal *} * </pre> * * @param candidate A candidate media type. Required. * @return True if the matcher matches the given media type. */ public boolean matches(final MediaType candidate) { return doFirst(ImmutableList.of(candidate)).isPresent(); }
/** * Given: * * <pre> * text/html, application/xhtml; {@literal *}/{@literal *} * </pre> * * <pre> * first(text/html) // returns text/html * first(application/json) // returns application/json * </pre> * * @param candidates One ore more candidates media type. Required. * @return A first most relevant media type or an empty optional. */ public Optional<MediaType> first(final List<MediaType> candidates) { return doFirst(candidates); }
/** * Given: * * <pre> * text/html, application/xhtml; {@literal *}/{@literal *} * </pre> * * <pre> * first(text/html) // returns text/html * first(application/json) // returns application/json * </pre> * * @param candidates One ore more candidates media type. Required. * @return A first most relevant media type or an empty optional. */ public Optional<MediaType> first(final List<MediaType> candidates) { return doFirst(candidates); }