Package org.jboss.resteasy.core

## Class MediaTypeMap<T>

- java.lang.Object
- - org.jboss.resteasy.core.MediaTypeMap<T>

-     public class MediaTypeMap<T>
      extends Object

  A copy-on-write MediaType index of T.
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `MediaTypeMap.Typed` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Pattern` | `COMPOSITE_SUBTYPE_WILDCARD_PATTERN` |
    `static boolean` | `useCache` | By default, MediaTypeMap will cache possible MediaType/Class matches.
    `static Pattern` | `WILD_SUBTYPE_COMPOSITE_PATTERN` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MediaTypeMap()` |
    `MediaTypeMap​(MediaTypeMap<T> mediaTypeMap)` | Shallow copy, any additional adds will deep copy

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(String mediaType, T obj)` | Add an object to the media type map.
    `void` | `add​(javax.ws.rs.core.MediaType type, T obj)` | Add an object to the media type map.
    `protected void` | `add​(org.jboss.resteasy.core.MediaTypeMap.Entry<T> entry)` |
    `void` | `addCompositeWild​(javax.ws.rs.core.MediaType mediaType, T obj, String baseSubtype)` |
    `void` | `addRegular​(javax.ws.rs.core.MediaType mediaType, T obj)` |
    `void` | `addWildcard​(T obj)` |
    `void` | `addWildComposite​(javax.ws.rs.core.MediaType mediaType, T obj, String baseSubtype)` |
    `void` | `addWildSubtype​(javax.ws.rs.core.MediaType mediaType, T obj)` |
    `static String` | `compositeWildSubtype​(String subtype)` |
    `List<T>` | `getPossible​(javax.ws.rs.core.MediaType accept)` | Returns a list of objects sorted based on their media type where the first in the list is the best match
    `List<T>` | `getPossible​(javax.ws.rs.core.MediaType accept, Class<?> type)` |
    `void` | `lockSnapshots()` | After this is called, all new adds will deep copy itself.
    `static String` | `wildCompositeSubtype​(String subtype)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### COMPOSITE_SUBTYPE_WILDCARD_PATTERN

          public static final Pattern COMPOSITE_SUBTYPE_WILDCARD_PATTERN

    - #### WILD_SUBTYPE_COMPOSITE_PATTERN

          public static final Pattern WILD_SUBTYPE_COMPOSITE_PATTERN

    - #### useCache

          public static boolean useCache

      By default, MediaTypeMap will cache possible MediaType/Class matches. Set this to false to turn off caching

  - ### Constructor Detail

    - #### MediaTypeMap

          public MediaTypeMap()

    - #### MediaTypeMap

          public MediaTypeMap​(MediaTypeMap<T> mediaTypeMap)

      Shallow copy, any additional adds will deep copy
      Parameters:
        `mediaTypeMap` -

  - ### Method Detail

    - #### compositeWildSubtype

          public static String compositeWildSubtype​(String subtype)

    - #### wildCompositeSubtype

          public static String wildCompositeSubtype​(String subtype)

    - #### lockSnapshots

          public void lockSnapshots()

      After this is called, all new adds will deep copy itself.

    - #### add

          public void add​(javax.ws.rs.core.MediaType type,
                          T obj)

      Add an object to the media type map. This is synchronized to serialize adds.
      Parameters:
        `type` - media type
        `obj` - object

    - #### add

          public void add​(String mediaType,
                          T obj)

      Add an object to the media type map. This is synchronized to serialize adds.
      Parameters:
        `mediaType` - media type
        `obj` - object

    - #### addWildcard

          public void addWildcard​(T obj)

    - #### add

          protected void add​(org.jboss.resteasy.core.MediaTypeMap.Entry<T> entry)

    - #### addRegular

          public void addRegular​(javax.ws.rs.core.MediaType mediaType,
                                 T obj)

    - #### addCompositeWild

          public void addCompositeWild​(javax.ws.rs.core.MediaType mediaType,
                                       T obj,
                                       String baseSubtype)

    - #### addWildComposite

          public void addWildComposite​(javax.ws.rs.core.MediaType mediaType,
                                       T obj,
                                       String baseSubtype)

    - #### addWildSubtype

          public void addWildSubtype​(javax.ws.rs.core.MediaType mediaType,
                                     T obj)

    - #### getPossible

          public List<T> getPossible​(javax.ws.rs.core.MediaType accept)

      Returns a list of objects sorted based on their media type where the first in the list is the best match
      Parameters:
        `accept` - mime to match
      Returns:
        list of objects

    - #### getPossible

          public List<T> getPossible​(javax.ws.rs.core.MediaType accept,
                                     Class<?> type)