aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java')
-rw-r--r--moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java109
1 files changed, 53 insertions, 56 deletions
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
index c11b406..453a331 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
@@ -31,12 +31,13 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * INTERNAL:
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * INTERNAL:
* <p><b>Purpose:</b>A wrapper class for a JDK Class. This implementation
* of the EclipseLink JAXB 2.X Java model simply makes reflective calls on the
* underlying JDK object.
@@ -76,15 +77,14 @@ public class JavaClassImpl implements JavaClass {
public void setJavaModelImpl(JavaModelImpl javaModel) {
this.javaModelImpl = javaModel;
- }
- public Collection getActualTypeArguments() {
- ArrayList<JavaClass> argCollection = new ArrayList<JavaClass>();
- if (jType instanceof ParameterizedType) {
- ParameterizedType pType = (ParameterizedType) jType;
- Type[] params = pType.getActualTypeArguments();
- for (Type type : params) {
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
+ }
+ public Collection getActualTypeArguments() {
+ ArrayList<JavaClass> argCollection = new ArrayList<JavaClass>();
+ if (jType != null) {
+ Type[] params = jType.getActualTypeArguments();
+ for (Type type : params) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
argCollection.add(new JavaClassImpl(pt, (Class) pt.getRawType(), javaModelImpl));
} else if(type instanceof WildcardType){
Type[] upperTypes = ((WildcardType)type).getUpperBounds();
@@ -129,25 +129,25 @@ public class JavaClassImpl implements JavaClass {
return new JavaAnnotationImpl(this.javaModelImpl.getAnnotationHelper().getAnnotation(getAnnotatedElement(), annotationClass));
}
}
- return null;
- }
-
- public Collection getAnnotations() {
- ArrayList<JavaAnnotation> annotationCollection = new ArrayList<JavaAnnotation>();
- if (!isMetadataComplete) {
- Annotation[] annotations = javaModelImpl.getAnnotationHelper().getAnnotations(getAnnotatedElement());
- for (Annotation annotation : annotations) {
+ return null;
+ }
+
+ public Collection<JavaAnnotation> getAnnotations() {
+ List<JavaAnnotation> annotationCollection = new ArrayList<JavaAnnotation>();
+ if (!isMetadataComplete) {
+ Annotation[] annotations = javaModelImpl.getAnnotationHelper().getAnnotations(getAnnotatedElement());
+ for (Annotation annotation : annotations) {
annotationCollection.add(new JavaAnnotationImpl(annotation));
}
}
- return annotationCollection;
- }
-
- public Collection getDeclaredClasses() {
- ArrayList<JavaClass> classCollection = new ArrayList<JavaClass>();
- Class[] classes = jClass.getDeclaredClasses();
- for (Class javaClass : classes) {
- classCollection.add(javaModelImpl.getClass(javaClass));
+ return annotationCollection;
+ }
+
+ public Collection<JavaClass> getDeclaredClasses() {
+ List<JavaClass> classCollection = new ArrayList<JavaClass>();
+ Class[] classes = jClass.getDeclaredClasses();
+ for (Class javaClass : classes) {
+ classCollection.add(javaModelImpl.getClass(javaClass));
}
return classCollection;
}
@@ -157,14 +157,14 @@ public class JavaClassImpl implements JavaClass {
return getJavaField(jClass.getDeclaredField(arg0));
} catch (NoSuchFieldException nsfe) {
return null;
- }
- }
-
- public Collection getDeclaredFields() {
- ArrayList<JavaField> fieldCollection = new ArrayList<JavaField>();
- Field[] fields = PrivilegedAccessHelper.getDeclaredFields(jClass);
-
- for (Field field : fields) {
+ }
+ }
+
+ public Collection<JavaField> getDeclaredFields() {
+ List<JavaField> fieldCollection = new ArrayList<JavaField>();
+ Field[] fields = PrivilegedAccessHelper.getDeclaredFields(jClass);
+
+ for (Field field : fields) {
field.setAccessible(true);
fieldCollection.add(getJavaField(field));
}
@@ -458,16 +458,13 @@ public class JavaClassImpl implements JavaClass {
return false;
}
if(arg0.getName().equals("java.lang.Object")) {
- return false;
- }
- JavaClassImpl jClass = (JavaClassImpl)arg0;
- if(jClass.getSuperClassOverride() != null) {
- return true;
- }
- return hasCustomSuperClass(jClass.getSuperclass());
- }
-
- public boolean isEnum() {
+ return false;
+ }
+ JavaClassImpl jClass = (JavaClassImpl)arg0;
+ return jClass.getSuperClassOverride() != null || hasCustomSuperClass(jClass.getSuperclass());
+ }
+
+ public boolean isEnum() {
return jClass.isEnum();
}
@@ -553,13 +550,13 @@ public class JavaClassImpl implements JavaClass {
}
}
return null;
- }
-
- public Collection getDeclaredAnnotations() {
- ArrayList<JavaAnnotation> annotationCollection = new ArrayList<JavaAnnotation>();
- if (!isMetadataComplete) {
- Annotation[] annotations = javaModelImpl.getAnnotationHelper().getDeclaredAnnotations(getAnnotatedElement());
- for (Annotation annotation : annotations) {
+ }
+
+ public Collection getDeclaredAnnotations() {
+ List<JavaAnnotation> annotationCollection = new ArrayList<JavaAnnotation>();
+ if (!isMetadataComplete) {
+ Annotation[] annotations = javaModelImpl.getAnnotationHelper().getDeclaredAnnotations(getAnnotatedElement());
+ for (Annotation annotation : annotations) {
annotationCollection.add(new JavaAnnotationImpl(annotation));
}
}