private Context createContext(Annotation[] annotations, Genson genson) { WithBeanView viewAnno = find(WithBeanView.class, annotations); Context context = null; if (viewAnno != null) context = new Context(genson, Arrays.asList(viewAnno.views())); else context = new Context(genson); return context; }
private Context createContext(Annotation[] annotations, Genson genson) { WithBeanView viewAnno = find(WithBeanView.class, annotations); Context context = null; if (viewAnno != null) context = new Context(genson, Arrays.asList(viewAnno.views())); else context = new Context(genson); return context; }
@SuppressWarnings("unchecked") @Override protected void writeInternal(Object t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { ObjectWriter writer = genson.createWriter(outputMessage.getBody()); MethodParameter mp = ThreadLocalHolder.get("__GENSON$return_param", MethodParameter.class); WithBeanView ann = mp != null ? mp.getMethodAnnotation(WithBeanView.class) : null; if (ann != null) genson.serialize(t, writer, new Context(genson, Arrays.asList(ann.views()))); else genson.serialize(t, writer, new Context(genson)); writer.flush(); } }
@SuppressWarnings("unchecked") @Override protected void writeInternal(Object t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { ObjectWriter writer = genson.createWriter(outputMessage.getBody()); MethodParameter mp = ThreadLocalHolder.get("__GENSON$return_param", MethodParameter.class); WithBeanView ann = mp != null ? mp.getMethodAnnotation(WithBeanView.class) : null; if (ann != null) genson.serialize(t, writer, new Context(genson, Arrays.asList(ann.views()))); else genson.serialize(t, writer, new Context(genson)); writer.flush(); } }
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MethodParameter mp = ThreadLocalHolder.get("__GENSON$method_param", MethodParameter.class); WithBeanView ann = null; Type type = clazz; if (mp != null) { ann = mp.getMethodAnnotation(WithBeanView.class); type = mp.getGenericParameterType(); } GenericType<?> genericType = GenericType.of(type); if (ann != null) return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson, Arrays.asList(ann.views()))); else return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson)); }
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MethodParameter mp = ThreadLocalHolder.get("__GENSON$method_param", MethodParameter.class); WithBeanView ann = null; Type type = clazz; if (mp != null) { ann = mp.getMethodAnnotation(WithBeanView.class); type = mp.getGenericParameterType(); } GenericType<?> genericType = GenericType.of(type); if (ann != null) return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson, Arrays.asList(ann.views()))); else return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson)); }