@SuppressWarnings("unchecked")
 @Override
 public T readFrom(
     Class<T> type,
     Type genericType,
     Annotation[] annotations,
     MediaType mediaType,
     MultivaluedMap<String, String> httpHeaders,
     InputStream entityStream)
     throws IOException, WebApplicationException {
   if (type.isAnnotationPresent(DTO.class)) {
     return DtoFactory.getInstance().createDtoFromJson(entityStream, type);
   } else if (type.isAssignableFrom(List.class) && genericType instanceof ParameterizedType) {
     ParameterizedType parameterizedType = (ParameterizedType) genericType;
     Type elementType = parameterizedType.getActualTypeArguments()[0];
     if (elementType instanceof Class) {
       Class elementClass = (Class) elementType;
       if (elementClass.isAnnotationPresent(DTO.class)) {
         return (T) DtoFactory.getInstance().createListDtoFromJson(entityStream, elementClass);
       }
     }
   }
   return (T)
       delegate.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
 }
 @SuppressWarnings("unchecked")
 @Override
 public boolean isWriteable(
     Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
   return !ignoredClasses.contains(type)
       && (type.isAnnotationPresent(DTO.class)
           || delegate.isWriteable(type, genericType, annotations, mediaType));
 }
 @SuppressWarnings("unchecked")
 @Override
 public void writeTo(
     T t,
     Class<?> type,
     Type genericType,
     Annotation[] annotations,
     MediaType mediaType,
     MultivaluedMap<String, Object> httpHeaders,
     OutputStream entityStream)
     throws IOException, WebApplicationException {
   // Add Cache-Control before start write body.
   httpHeaders.putSingle(HttpHeaders.CACHE_CONTROL, "public, no-cache, no-store, no-transform");
   if (t instanceof JsonSerializable) {
     try (Writer w = new OutputStreamWriter(entityStream, Charset.forName("UTF-8"))) {
       w.write(((JsonSerializable) t).toJson());
     }
   } else {
     delegate.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream);
   }
 }