@SuppressWarnings({"rawtypes", "unchecked"}) @Override protected Converter<?> create(Type type, Genson genson, Converter<?> nextConverter) { if (!Wrapper.toAnnotatedElement(nextConverter).isAnnotationPresent( HandleBeanView.class)) // TODO as we link an instance to a type, we may optimize things, but for the moment it is okay // lets see if this feature is used return new BeanViewConverter(type, provider, nextConverter); return nextConverter; } }
public void serialize(T obj, ObjectWriter writer, Context ctx) throws Exception { boolean handled = false; List<Class<? extends BeanView<?>>> views = ctx.views(); if (views != null && views.size() > 0) { Class<? extends BeanView<T>> viewClass = findViewFor(type, views); if (viewClass != null) { Type viewForType = TypeUtil.expandType(BeanView.class.getTypeParameters()[0], viewClass); @SuppressWarnings("unchecked") Class<T> viewForClass = (Class<T>) TypeUtil.getRawClass(viewForType); BeanDescriptor<T> descriptor = provider .provide(viewForClass, viewClass, ctx.genson); descriptor.serialize(obj, writer, ctx); handled = true; } } if (!handled) wrapped.serialize(obj, writer, ctx); }
public void serialize(T obj, ObjectWriter writer, Context ctx) throws Exception { boolean handled = false; List<Class<? extends BeanView<?>>> views = ctx.views(); if (views != null && views.size() > 0) { Class<? extends BeanView<T>> viewClass = findViewFor(type, views); if (viewClass != null) { Type viewForType = TypeUtil.expandType(BeanView.class.getTypeParameters()[0], viewClass); @SuppressWarnings("unchecked") Class<T> viewForClass = (Class<T>) TypeUtil.getRawClass(viewForType); BeanDescriptor<T> descriptor = provider .provide(viewForClass, viewClass, ctx.genson); descriptor.serialize(obj, writer, ctx); handled = true; } } if (!handled) wrapped.serialize(obj, writer, ctx); }
public T deserialize(ObjectReader reader, Context ctx) throws Exception { if (ctx.hasViews()) { Class<? extends BeanView<T>> viewClass = findViewFor(type, ctx.views()); if (viewClass != null) { Type viewForType = TypeUtil.expandType(BeanView.class.getTypeParameters()[0], viewClass); @SuppressWarnings("unchecked") Class<T> viewForClass = (Class<T>) TypeUtil.getRawClass(viewForType); BeanDescriptor<T> descriptor = provider .provide(viewForClass, viewClass, ctx.genson); return descriptor.deserialize(reader, ctx); } } return wrapped.deserialize(reader, ctx); } }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override protected Converter<?> create(Type type, Genson genson, Converter<?> nextConverter) { if (!Wrapper.toAnnotatedElement(nextConverter).isAnnotationPresent( HandleBeanView.class)) // TODO as we link an instance to a type, we may optimize things, but for the moment it is okay // lets see if this feature is used return new BeanViewConverter(type, provider, nextConverter); return nextConverter; } }
public T deserialize(ObjectReader reader, Context ctx) throws Exception { if (ctx.hasViews()) { Class<? extends BeanView<T>> viewClass = findViewFor(type, ctx.views()); if (viewClass != null) { Type viewForType = TypeUtil.expandType(BeanView.class.getTypeParameters()[0], viewClass); @SuppressWarnings("unchecked") Class<T> viewForClass = (Class<T>) TypeUtil.getRawClass(viewForType); BeanDescriptor<T> descriptor = provider .provide(viewForClass, viewClass, ctx.genson); return descriptor.deserialize(reader, ctx); } } return wrapped.deserialize(reader, ctx); } }