public static Response copyResponseIfNeeded(Response response) { if (!(response instanceof ResponseImpl)) { Response r = fromResponse(response).build(); Field[] declaredFields = ReflectionUtil.getDeclaredFields(response.getClass()); for (Field f : declaredFields) { Class<?> declClass = f.getType(); if (declClass == Annotation[].class) { try { Annotation[] fieldAnnotations = ReflectionUtil.accessDeclaredField(f, response, Annotation[].class); ((ResponseImpl)r).setEntityAnnotations(fieldAnnotations); } catch (Throwable ex) { LOG.warning("Custom annotations if any can not be copied"); } break; } } return r; } return response; }
public static Response copyResponseIfNeeded(Response response) { if (!(response instanceof ResponseImpl)) { Response r = fromResponse(response).build(); Field[] declaredFields = ReflectionUtil.getDeclaredFields(response.getClass()); for (Field f : declaredFields) { Class<?> declClass = f.getType(); if (declClass == Annotation[].class) { try { Annotation[] fieldAnnotations = ReflectionUtil.accessDeclaredField(f, response, Annotation[].class); ((ResponseImpl)r).setEntityAnnotations(fieldAnnotations); } catch (Throwable ex) { LOG.warning("Custom annotations if any can not be copied"); } break; } } return r; } else { return response; } }