Author: bluk
Date: Mon Mar 22 15:47:41 2010
New Revision: 926147
URL: http://svn.apache.org/viewvc?rev=926147&view=rev
Log:
Do a compatibility check in GenericEntity
Modified:
cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
Modified:
cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java?rev=926147&r1=926146&r2=926147&view=diff
==============================================================================
---
cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
(original)
+++
cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
Mon Mar 22 15:47:41 2010
@@ -47,19 +47,28 @@ public class GenericEntity<T> {
throw new IllegalArgumentException();
}
+ checkCompatibility(entity.getClass(), genericType);
this.entity = entity;
this.genericType = genericType;
}
+ private void checkCompatibility(Class<?> rawType, Type genericType) {
+ if (genericType instanceof Class<?>) {
+ if (!((Class<?>)genericType).isAssignableFrom(rawType)) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
public T getEntity() {
return entity;
}
- public java.lang.Class<?> getRawType() {
+ public Class<?> getRawType() {
return entity.getClass();
}
- public java.lang.reflect.Type getType() {
+ public Type getType() {
return genericType;
}
}