예제 #1
0
  /** Returns the component type of this (array or collection) type. */
  public Class<?> getComponentType() {
    Class<?> type = getType();
    if (type.isArray()) {
      return type.getComponentType();

    } else if (Collection.class.isAssignableFrom(type)) {
      return getArgumentType(Collection.class);
    }
    return null;
  }
예제 #2
0
 /** Returns the message bundle to use when translating the supplied class's properties. */
 public static String getMessageBundle(Class<?> clazz) {
   while (clazz.isArray()) {
     clazz = clazz.getComponentType();
   }
   if (clazz.isPrimitive()) {
     return EditorMessageBundle.DEFAULT;
   }
   String bundle = _bundles.get(clazz);
   if (bundle == null) {
     _bundles.put(clazz, bundle = findMessageBundle(clazz));
   }
   return bundle;
 }
예제 #3
0
  /** Returns the generic component type of this (array or collection) type. */
  public Type getGenericComponentType() {
    Class<?> type = getType();
    Type gtype = getGenericType();
    if (gtype instanceof GenericArrayType) {
      return ((GenericArrayType) gtype).getGenericComponentType();

    } else if (type.isArray()) {
      return type.getComponentType();

    } else if (Collection.class.isAssignableFrom(type)) {
      return getGenericArgumentType(Collection.class);
    }
    return null;
  }