@Override
  public void writeTo(
      JAXBElement<?> t,
      Class<?> type,
      Type genericType,
      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream outputStream)
      throws IOException {

    Class<?> typeArg = Object.class;
    if (genericType != null) typeArg = Types.getTypeArgument(genericType);
    super.writeTo(t, typeArg, genericType, annotations, mediaType, httpHeaders, outputStream);
  }
 public JAXBElement<?> readFrom(
     Class<JAXBElement<?>> type,
     Type genericType,
     Annotation[] annotations,
     MediaType mediaType,
     MultivaluedMap<String, String> httpHeaders,
     InputStream entityStream)
     throws IOException {
   NoContent.contentLengthCheck(httpHeaders);
   Class<?> typeArg = Object.class;
   if (genericType != null) typeArg = Types.getTypeArgument(genericType);
   JAXBContext jaxb = null;
   try {
     jaxb = findJAXBContext(typeArg, annotations, mediaType, true);
   } catch (JAXBException e) {
     throw new JAXBUnmarshalException(e);
   }
   JAXBElement<?> result;
   try {
     Unmarshaller unmarshaller = jaxb.createUnmarshaller();
     unmarshaller = decorateUnmarshaller(type, annotations, mediaType, unmarshaller);
     if (suppressExpandEntityExpansion()) {
       unmarshaller = new ExternalEntityUnmarshaller(unmarshaller);
       SAXSource source = new SAXSource(new InputSource(entityStream));
       result = unmarshaller.unmarshal(source, (Class<?>) typeArg);
     } else {
       JAXBElement<?> e =
           unmarshaller.unmarshal(new StreamSource(entityStream), (Class<?>) typeArg);
       result = e;
     }
     ;
   } catch (JAXBException e) {
     throw new JAXBUnmarshalException(e);
   }
   JAXBElement<?> element = result;
   return element;
 }