Update of /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21308/metadata/src/java/org/hibernate/reflection Modified Files: XClass.java XAnnotatedElement.java XProperty.java ReflectionManager.java XPackage.java Log Message: Support for generics in reflection layer Index: XClass.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection/XClass.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XClass.java 26 Jan 2006 15:02:55 -0000 1.3 +++ XClass.java 13 Feb 2006 19:14:35 -0000 1.4 @@ -1,32 +1,31 @@ package org.hibernate.reflection; +import java.lang.reflect.Method; import java.util.List; /** * @author Paolo Perrotta * @author Davide Marchignoli */ -public interface XClass<T> extends XAnnotatedElement { +public interface XClass extends XAnnotatedElement { - String getName(); + String getName(); - XPackage getPackage(); - - XClass getSuperclass(); + XClass getSuperclass(); - boolean isAbstract(); + boolean isAbstract(); - boolean isPrimitive(); + boolean isPrimitive(); - boolean isEnum(); + boolean isEnum(); - boolean isAssignableFrom(XClass c); + boolean isAssignableFrom(XClass c); - // TODO: remove the parameter by pushing the access type guessing down here? emmanuel: I'm -1 List<XProperty> getDeclaredProperties(String accessType); - //TODO emmanuel: we need to add a getDeclaredMethods for EntityManager and possibly Validator - - // TODO: this one must die - Class<T> toClass(); + /** + * Returns the Java <tt>Method</tt>s defined by this class. + */ + // TODO: not called right now. is it still useful? if so, is there any way to avoid it? + Method[] getDeclaredMethods(); } Index: XAnnotatedElement.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection/XAnnotatedElement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XAnnotatedElement.java 24 Jan 2006 16:01:02 -0000 1.1 +++ XAnnotatedElement.java 13 Feb 2006 19:14:35 -0000 1.2 @@ -8,9 +8,9 @@ */ public interface XAnnotatedElement { - <T extends Annotation> T getAnnotation(Class<T> annotationType); + <T extends Annotation> T getAnnotation(Class<T> annotationType); - <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType); - - Annotation[] getAnnotations(); + <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType); + + Annotation[] getAnnotations(); } Index: XProperty.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection/XProperty.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XProperty.java 26 Jan 2006 15:02:55 -0000 1.3 +++ XProperty.java 13 Feb 2006 19:14:35 -0000 1.4 @@ -2,40 +2,38 @@ import java.util.Collection; - /** * @author Paolo Perrotta * @author Davide Marchignoli */ public interface XProperty extends XAnnotatedElement { - String getName(); + String getName(); - boolean isCollection(); + boolean isCollection(); - boolean isArray(); + boolean isArray(); - /** - * Returns either the type of this property (for single values), or - * the type of this property's elements (for Collections and arrays). - * @return The type of this property or its elements, or null if it cannot guess it. - */ - // TODO: the idea is to refactor the binding layer enough that we can uniformily deal with - // "single values" and "multiple values" (collections and arrays) in most situations. - // We hope it can be done. Right now, this method might as well be two separate methods - // getClass() and getElementClass(). - // emmanuel: I don't understand the idea - XClass getClassOrElementClass(); + // TODO We should probably try to reduce the following four methods to two or three at most. + // the last one is particularly offensive - /** - * @return the raw class of this property, assuming that this property is a Collection (List.class, etc.). - * - * @throws RuntimeException if !isCollection() - */ - Class<? extends Collection> getCollectionClass(); - - // TODO: this stuff is temporary - the root entity should be guessed within this layer - // remove after the refactoring to the X layer is done, and just use getClassOrElementClass() - XClass getType(XClass rootEntity); - XClass getClassOrElement(XClass rootEntity); + /** + * The collection class for collections, null for others. + */ + Class<? extends Collection> getCollectionClass(); + + /** + * This property's XClass. + */ + XClass getType(); + + /** + * This property's type for simple properties, the type of its elements for arrays and collections. + */ + XClass getElementClass(); + + /** + * The type of this property's elements for arrays, the type of the property itself for everything else. + */ + XClass getClassOrElementClass(); } Index: ReflectionManager.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection/ReflectionManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ReflectionManager.java 25 Jan 2006 21:48:21 -0000 1.2 +++ ReflectionManager.java 13 Feb 2006 19:14:35 -0000 1.3 @@ -1,6 +1,6 @@ package org.hibernate.reflection; -import org.hibernate.reflection.java.JavaReflectionManager; +import org.hibernate.reflection.java.JavaXFactory; /** * The entry point to the reflection layer (a.k.a. the X* layer). @@ -10,12 +10,14 @@ */ public interface ReflectionManager { - // TODO: turn this Singleton into a plug-in - public static final JavaReflectionManager INSTANCE = new JavaReflectionManager(); + // TODO: turn this Singleton into a plug-in + public static final JavaXFactory INSTANCE = new JavaXFactory(); - public <T> XClass<T> toXClass(Class<T> clazz); - - public <T> XClass<T> classForName(String name, Class<T> caller) throws ClassNotFoundException; - - public XPackage packageForName(String packageName) throws ClassNotFoundException; + public <T> XClass toXClass(Class<T> clazz); + + public <T> XClass classForName(String name, Class<T> caller) throws ClassNotFoundException; + + public XPackage packageForName(String packageName) throws ClassNotFoundException; + + public <T> boolean equals(XClass class1, Class<T> class2); } Index: XPackage.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/reflection/XPackage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPackage.java 24 Jan 2006 16:01:02 -0000 1.1 +++ XPackage.java 13 Feb 2006 19:14:35 -0000 1.2 @@ -6,5 +6,5 @@ */ public interface XPackage extends XAnnotatedElement { - String getName(); + String getName(); } |