List of usage examples for java.lang Class getSuperclass
@HotSpotIntrinsicCandidate public native Class<? super T> getSuperclass();
From source file:com.cnksi.core.tools.utils.Reflections.java
public static Class<?> getUserClass(Object instance) { Validate.notNull(instance, "Instance must not be null"); Class clazz = instance.getClass(); if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { Class<?> superClass = clazz.getSuperclass(); if (superClass != null && !Object.class.equals(superClass)) { return superClass; }/*ww w. java 2 s. co m*/ } return clazz; }
From source file:Main.java
public static ArrayList<Class<?>> buildClassHierarchy(Class<?> cls) { ArrayList<Class<?>> hierarhy = new ArrayList<Class<?>>(); boolean enteredDroidParts = false; do {// w ww . j a va 2 s.c o m hierarhy.add(0, cls); boolean inDroidParts = cls.getName().startsWith("org.droidparts"); if (enteredDroidParts && !inDroidParts) { break; } else { enteredDroidParts = inDroidParts; cls = cls.getSuperclass(); } } while (cls != null); return hierarhy; }
From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java
public static ArrayList<Field> getAllFields(Class clazz) { ArrayList<Field> returnFields = new ArrayList<Field>(); while (clazz != null) { Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { returnFields.add(field);//from w w w . j a v a 2 s . c om } clazz = clazz.getSuperclass(); } return returnFields; }
From source file:springobjectmapper.ReflectionHelper.java
public static Field getField(Class<?> c, String name) { do {//from w w w. j av a2s .c om try { Field field = c.getDeclaredField(name); field.setAccessible(true); return field; } catch (NoSuchFieldException ex) { } catch (Exception e) { ReflectionUtils.handleReflectionException(e); } c = c.getSuperclass(); } while (c != null); throw new RuntimeException("Field " + name + " was not found!"); }
From source file:com.manydesigns.portofino.pageactions.PageActionLogic.java
public static boolean supportsDetail(Class<?> actionClass) { if (!PageAction.class.isAssignableFrom(actionClass)) { return false; }/*from w ww . j a v a2s . c o m*/ SupportsDetail supportsDetail = actionClass.getAnnotation(SupportsDetail.class); if (supportsDetail != null) { return supportsDetail.value(); } else { return supportsDetail(actionClass.getSuperclass()); } }
From source file:Main.java
public static List<Field> listAnnotatedFields(Class<?> cls) { ArrayList<Class<?>> clsTree = new ArrayList<Class<?>>(); boolean enteredDroidParts = false; do {/* w ww. ja v a2 s .co m*/ clsTree.add(0, cls); boolean inDroidParts = cls.getName().startsWith("org.droidparts"); if (enteredDroidParts && !inDroidParts) { break; } else { enteredDroidParts = inDroidParts; cls = cls.getSuperclass(); } } while (cls != null); ArrayList<Field> fields = new ArrayList<Field>(); for (Class<?> c : clsTree) { for (Field f : c.getDeclaredFields()) { if (f.getAnnotations().length > 0) { fields.add(f); } } } return fields; }
From source file:net.cloudkit.enterprises.infrastructure.utilities.ReflectionHelper.java
public static Class<?> getUserClass(Object instance) { Validate.notNull(instance, "Instance must not be null"); Class<?> clazz = instance.getClass(); if ((clazz != null) && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { Class<?> superClass = clazz.getSuperclass(); if ((superClass != null) && !Object.class.equals(superClass)) { return superClass; }/* w w w . j a v a 2s .c o m*/ } return clazz; }
From source file:com.acuityph.commons.jpa.JpaUtils.java
/** * @param entityClass/* w w w .j a v a 2s .co m*/ * the entity class to inspect * @return the {@link Field} annotated with @Id, or null if no such field * was found */ public static Field determineIdField(final Class<?> entityClass) { Field idField = null; Class<?> cl = entityClass; while (idField == null && cl != null && cl != Object.class) { for (final Field field : cl.getDeclaredFields()) { if (field.getAnnotation(Id.class) != null) { idField = field; break; } } if (idField == null) { cl = cl.getSuperclass(); } } return idField; }
From source file:com.cassius.spring.assembly.test.common.reflect.FieldReader.java
/** * New instance.//from www . j a va 2 s . c o m * * @param object the object * @param fieldName the field name * @return the field reader * @throws NoSuchFieldException the no such field exception */ public static FieldReader newInstance(Object object, String fieldName) throws NoSuchFieldException { Class<?> clazz = object.getClass(); while (clazz != Object.class) { try { Field field = clazz.getDeclaredField(fieldName); if (field != null) { return newInstance(object, field); } } catch (NoSuchFieldException ignore) { } clazz = clazz.getSuperclass(); } throw new NoSuchFieldException(fieldName + "not exist"); }
From source file:net.landora.video.utils.UIUtils.java
public static MultiValueMap createCompleteContextByClass(Collection<?> context) { Collection<Object> fullContext = UIUtils.createCompleteContext(context); MultiValueMap valuesByClass = new MultiValueMap(); Set<Class<?>> allClasses = new HashSet<Class<?>>(); for (Object obj : fullContext) { Class<?> clazz = obj.getClass(); allClasses.clear();/*from w w w . java 2s.c om*/ while (clazz != null) { allClasses.add(clazz); allClasses.addAll(Arrays.asList(clazz.getInterfaces())); clazz = clazz.getSuperclass(); } for (Class<?> c : allClasses) { valuesByClass.put(c, obj); } } return valuesByClass; }