Class MediaTypes


  • public final class MediaTypes
    extends java.lang.Object

    Utility methods and constants for the Guava MediaType class

    Since:
    2.0
    Version:
    4.0.5
    Author:
    Michael Grove
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static com.google.common.net.MediaType HTML  
      static com.google.common.net.MediaType JSON  
      static com.google.common.net.MediaType MULTIPART_FORM_DATA  
      static com.google.common.net.MediaType MULTIPART_MIXED  
      static com.google.common.net.MediaType TEXT  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean any​(com.google.common.net.MediaType theType, com.google.common.net.MediaType theFirst, com.google.common.net.MediaType... theRest)  
      static java.util.function.Predicate<com.google.common.net.MediaType> is​(com.google.common.net.MediaType theType)  
      static boolean isCompatibleWith​(com.google.common.net.MediaType theType, com.google.common.net.MediaType theOtherType)  
      static java.util.function.Predicate<com.google.common.net.MediaType> isCompatibleWith​(java.lang.String theType)  
      static boolean isCompatibleWith​(java.lang.String theType, java.lang.String theOtherType)  
      static boolean isMultipart​(com.google.common.net.MediaType theType)  
      static com.google.common.net.MediaType parseMime​(java.lang.String theMime)
      Parse the provide mime-type string into a MediaType.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MULTIPART_FORM_DATA

        public static final com.google.common.net.MediaType MULTIPART_FORM_DATA
      • MULTIPART_MIXED

        public static final com.google.common.net.MediaType MULTIPART_MIXED
      • JSON

        public static final com.google.common.net.MediaType JSON
      • TEXT

        public static final com.google.common.net.MediaType TEXT
      • HTML

        public static final com.google.common.net.MediaType HTML
    • Method Detail

      • is

        public static java.util.function.Predicate<com.google.common.net.MediaType> is​(com.google.common.net.MediaType theType)
      • any

        public static boolean any​(com.google.common.net.MediaType theType,
                                  com.google.common.net.MediaType theFirst,
                                  com.google.common.net.MediaType... theRest)
      • isCompatibleWith

        public static boolean isCompatibleWith​(com.google.common.net.MediaType theType,
                                               com.google.common.net.MediaType theOtherType)
      • isCompatibleWith

        public static boolean isCompatibleWith​(java.lang.String theType,
                                               java.lang.String theOtherType)
      • isCompatibleWith

        public static java.util.function.Predicate<com.google.common.net.MediaType> isCompatibleWith​(java.lang.String theType)
      • isMultipart

        public static boolean isMultipart​(com.google.common.net.MediaType theType)
      • parseMime

        public static com.google.common.net.MediaType parseMime​(java.lang.String theMime)

        Parse the provide mime-type string into a MediaType. For the most part this is just a thin wrapper around MediaType.parse(String), however, the parse method does not handle normalization of parameters, primarily, charset. However, MediaType.withParameters(com.google.common.collect.Multimap) does, so the result is passed through withParameters for normalization before returning the final result.

        null is interpreted to be MediaType.ANY_TYPE

        Parameters:
        theMime - the mime-type as a string
        Returns:
        the corresponding MediaType