private <T> T doDecoration(T target, Class type, Annotation[] annotations, MediaType mediaType, Annotation annotation, Decorator decorator) { DecoratorProcessor processor = null; try { processor = decorator.processor().newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e.getCause()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } target = (T) processor.decorate(target, annotation, type, annotations, mediaType); return target; }
private <T> void putMeta(Class<T> targetClass, HashMap<Class<?>, Annotation> meta, Annotation annotation, Decorator decorator) { if (decorator != null && targetClass.isAssignableFrom(decorator.target())) { meta.put(annotation.annotationType(), annotation); } } }
public <T> boolean hasDecorator(Class<T> targetClass, Annotation[] annotations) { if (targetClass == null || annotations == null) return false; for (Annotation annotation : annotations) { Decorators decorators = annotation.annotationType().getAnnotation(Decorators.class); if (decorators != null) { for (Decorator decorator : decorators.values()) { if (decorator != null && decorator.target().isAssignableFrom(targetClass)) return true; } } else { Decorator decorator = annotation.annotationType().getAnnotation(Decorator.class); if (decorator != null && decorator.target().isAssignableFrom(targetClass)) return true; } } return false; }
private void injectDecorator(MediaTypeMap<Class<?>> typeMap, Class<?> decoratorAnnotation, Decorator decorator) { String[] mediaTypes = {"*/*"}; DecorateTypes produces = decorator.processor().getAnnotation(DecorateTypes.class); if (produces != null) { mediaTypes = produces.value(); } for (String pType : mediaTypes) { typeMap.add(MediaType.valueOf(pType), decoratorAnnotation); } }
if (decorators != null) { for (Decorator decorator : decorators.values()) { if (decorator.target().isAssignableFrom(target.getClass())) { target = doDecoration(target, type, annotations, mediaType, annotation, decorator);
private <T> T doDecoration(T target, Class type, Annotation[] annotations, MediaType mediaType, Annotation annotation, Decorator decorator) { DecoratorProcessor processor = null; try { processor = decorator.processor().newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e.getCause()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } target = (T) processor.decorate(target, annotation, type, annotations, mediaType); return target; }
private <T> void putMeta(Class<T> targetClass, HashMap<Class<?>, Annotation> meta, Annotation annotation, Decorator decorator) { if (decorator != null && targetClass.isAssignableFrom(decorator.target())) { meta.put(annotation.annotationType(), annotation); } } }
private void injectDecorator(MediaTypeMap<Class<?>> typeMap, Class<?> decoratorAnnotation, Decorator decorator) { String[] mediaTypes = {"*/*"}; DecorateTypes produces = decorator.processor().getAnnotation(DecorateTypes.class); if (produces != null) { mediaTypes = produces.value(); } for (String pType : mediaTypes) { typeMap.add(MediaType.valueOf(pType), decoratorAnnotation); } }
private <T> void registerDecorators(Class<T> targetClass, HashMap<Class<?>, Annotation> meta, Annotation[] annotations) { for (Annotation annotation : annotations) { Decorator decorator = annotation.annotationType().getAnnotation(Decorator.class); if (decorator != null && targetClass.isAssignableFrom(decorator.target())) { meta.put(annotation.annotationType(), annotation); } } } }
public <T> boolean hasDecorator(Class<T> targetClass, Annotation[] annotations) { if (targetClass == null || annotations == null) return false; for (Annotation annotation : annotations) { Decorators decorators = annotation.annotationType().getAnnotation(Decorators.class); if (decorators != null) { for (Decorator decorator : decorators.values()) { if (decorator != null && decorator.target().isAssignableFrom(targetClass)) return true; } } else { Decorator decorator = annotation.annotationType().getAnnotation(Decorator.class); if (decorator != null && decorator.target().isAssignableFrom(targetClass)) return true; } } return false; }
if (decorators != null) { for (Decorator decorator : decorators.values()) { if (decorator.target().isAssignableFrom(target.getClass())) { target = doDecoration(target, type, annotations, mediaType, annotation, decorator);