// override any class level ones
if (annotations != null)
{
for (Annotation annotation : annotations)
{
Decorator decorator = annotation.annotationType().getAnnotation(Decorator.class);
if (decorator != null && targetClass.isAssignableFrom(decorator.target()))
{
meta.put(annotation.annotationType(), annotation);
}
}
}
if (meta.size() == 0) return target;
MediaTypeMap<Class<?>> typeMap = new MediaTypeMap<Class<?>>();
for (Class<?> decoratorAnnotation : meta.keySet())
{
Decorator decorator = decoratorAnnotation.getAnnotation(Decorator.class);
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);
}
}
List<Class<?>> list = typeMap.getPossible(mediaType);
for (Class<?> decoratorAnnotation : list)
{
Annotation annotation = meta.get(decoratorAnnotation);
Decorator decorator = decoratorAnnotation.getAnnotation(Decorator.class);
DecoratorProcessor processor = null;
try
{
processor = decorator.processor().newInstance();
}
catch (InstantiationException e)
{
throw new RuntimeException(e.getCause());
}