[jboss-cvs] JBossAS SVN: r95293 - projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 21 09:30:39 EDT 2009
Author: alesj
Date: 2009-10-21 09:30:39 -0400 (Wed, 21 Oct 2009)
New Revision: 95293
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
Log:
ClassInfo shouldn't return all annotations.
TODO - tests.
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2009-10-21 13:27:41 UTC (rev 95292)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2009-10-21 13:30:39 UTC (rev 95293)
@@ -36,6 +36,7 @@
import org.jboss.reflect.spi.PackageInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.util.JBossStringBuilder;
/**
@@ -44,6 +45,7 @@
* TODO JBMICROCONT-118 fix the introspection assumption
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
public class ClassInfoImpl extends InheritableAnnotationHolder implements ClassInfo
{
@@ -171,6 +173,26 @@
this.superclass = superclass;
}
+ // TODO - test this!
+
+ @Override
+ public AnnotationValue[] getAnnotations()
+ {
+ return getDeclaredAnnotations();
+ }
+
+ @Override
+ public AnnotationValue getAnnotation(String name)
+ {
+ return getDeclaredAnnotation(name);
+ }
+
+ @Override
+ public boolean isAnnotationPresent(String name)
+ {
+ return isDeclaredAnnotationPresent(name);
+ }
+
public TypeInfoFactory getTypeInfoFactory()
{
return typeInfoFactory;
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2009-10-21 13:27:41 UTC (rev 95292)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2009-10-21 13:30:39 UTC (rev 95293)
@@ -33,6 +33,7 @@
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
public abstract class InheritableAnnotationHolder extends AbstractAnnotatedInfo
{
@@ -88,13 +89,51 @@
*
* @return the declared annotations
*/
- public AnnotationValue[] getDeclaredAnnotations()
+ protected AnnotationValue[] getDeclaredAnnotations()
{
if (declaredAnnotationsArray == UNKNOWN_ANNOTATIONS)
setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return declaredAnnotationsArray;
}
+ /**
+ * Get the declared annotations
+ *
+ * @param name the annotation name
+ * @return the declared annotations
+ */
+ protected AnnotationValue getDeclaredAnnotation(String name)
+ {
+ if (declaredAnnotations == UNKNOWN_ANNOTATIONS_MAP)
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
+ return declaredAnnotations.get(name);
+ }
+
+ /**
+ * Is declared annotation present.
+ *
+ * @param name the annotation name
+ * @return true if the annotation is present, false otherwise
+ */
+ protected boolean isDeclaredAnnotationPresent(String name)
+ {
+ if (declaredAnnotations == UNKNOWN_ANNOTATIONS_MAP)
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
+ return declaredAnnotations.containsKey(name);
+ }
+
+ /**
+ * Get all the annotations as a map
+ *
+ * @return the map
+ */
+ protected Map<String, AnnotationValue> getAllAnnotations()
+ {
+ if (allAnnotations == UNKNOWN_ANNOTATIONS_MAP)
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
+ return allAnnotations;
+ }
+
public AnnotationValue[] getAnnotations()
{
if (allAnnotationsArray == UNKNOWN_ANNOTATIONS)
@@ -162,20 +201,8 @@
}
}
}
-
+
/**
- * Get all the annotations as a map
- *
- * @return the map
- */
- protected Map<String, AnnotationValue> getAllAnnotations()
- {
- if (allAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
- return allAnnotations;
- }
-
- /**
* Get the super holder of annoations
*
* @return the super holder
More information about the jboss-cvs-commits
mailing list