Class MediaTypes

  • public final class MediaTypes
    extends java.lang.Object

    Utility methods and constants for the Guava MediaType class

    Michael Grove
    • Field Summary

      Modifier and Type Field Description
      static HTML  
      static JSON  
      static MULTIPART_FORM_DATA  
      static MULTIPART_MIXED  
      static TEXT  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean any​( theType, theFirst, theRest)  
      static java.util.function.Predicate<> is​( theType)  
      static boolean isCompatibleWith​( theType, theOtherType)  
      static java.util.function.Predicate<> isCompatibleWith​(java.lang.String theType)  
      static boolean isCompatibleWith​(java.lang.String theType, java.lang.String theOtherType)  
      static boolean isMultipart​( theType)  
      static 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


        public static final MULTIPART_FORM_DATA

        public static final MULTIPART_MIXED
      • JSON

        public static final JSON
      • TEXT

        public static final TEXT
      • HTML

        public static final HTML
    • Method Detail

      • is

        public static java.util.function.Predicate<> is​( theType)
      • any

        public static boolean any​( theType,
      • isCompatibleWith

        public static boolean isCompatibleWith​( theType,
      • isCompatibleWith

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

        public static java.util.function.Predicate<> isCompatibleWith​(java.lang.String theType)
      • isMultipart

        public static boolean isMultipart​( theType)
      • parseMime

        public static 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( does, so the result is passed through withParameters for normalization before returning the final result.

        null is interpreted to be MediaType.ANY_TYPE

        theMime - the mime-type as a string
        the corresponding MediaType