@Test public void testGetAnnotation() { Annotation[] annotations = new Annotation[2]; annotations[0] = SampleType.class.getAnnotation(XmlType.class); annotations[1] = JsonXMLDefault.class.getAnnotation(JsonXML.class); Assert.assertEquals(XmlType.class, AbstractJsonXMLProvider.getAnnotation(annotations, XmlType.class).annotationType()); Assert.assertEquals(JsonXML.class, AbstractJsonXMLProvider.getAnnotation(annotations, JsonXML.class).annotationType()); Assert.assertNull(AbstractJsonXMLProvider.getAnnotation(annotations, XmlRootElement.class)); }
protected static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType() == annotationType) { return annotationType.cast(annotation); } } return null; }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType() == annotationType) { return annotationType.cast(annotation); } } return null; } }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType() == annotationType) { return annotationType.cast(annotation); } } return null; } AbstractJsonXMLProvider(Providers providers); }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType() == annotationType) { return annotationType.cast(annotation); } } return null; } AbstractJsonXMLProvider(Providers providers); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); abstract Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader entityStream); @Override final Object readFrom(
			Class<Object> type, // <-- how sad...
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			InputStream entityStream); abstract void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer entityStream,
			Object entry); @Override final void writeTo(
			Object entry,
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			OutputStream entityStream); }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected static <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType() == annotationType) { return annotationType.cast(annotation); } } return null; } AbstractJsonXMLProvider(Providers providers); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); abstract Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader entityStream); @Override final Object readFrom(
			Class<Object> type, // <-- how sad...
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			InputStream entityStream); abstract void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer entityStream,
			Object entry); @Override final void writeTo(
			Object entry,
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			OutputStream entityStream);  }