Example usage for java.lang Class getSuperclass

List of usage examples for java.lang Class getSuperclass

Introduction

In this page you can find the example usage for java.lang Class getSuperclass.

Prototype

@HotSpotIntrinsicCandidate
public native Class<? super T> getSuperclass();

Source Link

Document

Returns the Class representing the direct superclass of the entity (class, interface, primitive type or void) represented by this Class .

Usage

From source file:grails.plugin.springsecurity.acl.util.ProxyUtils.java

protected static boolean isProxy(Class<?> clazz) {
    if (clazz.getSuperclass() == Object.class) {
        return false;
    }/* w  w  w . j  ava  2s . com*/
    return isCglibProxyClass(clazz) || isJavassistProxy(clazz);
}

From source file:Main.java

private static List<Field> getClassFields(Class clazz) {
    ArrayList<Field> fields = new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()));
    if (clazz.getSuperclass() != null) {
        fields.addAll(getClassFields(clazz.getSuperclass()));
    }//ww  w .j av  a 2s.  c  o  m
    return fields;
}

From source file:com.francetelecom.clara.cloud.presentation.utils.GetObjectsUtils.java

public static Field[] getAllFields(Class objectClass) {
    if (objectClass.getSuperclass() == null) {
        return null;
    }/* w  w w.  ja v  a 2  s  .c o m*/
    return (Field[]) ArrayUtils.addAll(objectClass.getDeclaredFields(),
            getAllFields(objectClass.getSuperclass()));
}

From source file:Main.java

private static Object getSupperField(Object obj, Class<?> cls, String fieldName) throws NoSuchFieldException {
    Class superclass = cls.getSuperclass();
    while (superclass != null) {
        try {/*from w ww.  jav  a2  s  . co  m*/
            return getDeclaredField(obj, superclass, fieldName);
        } catch (NoSuchFieldException e) {
            try {
                superclass = superclass.getSuperclass();
            } catch (Exception e2) {
                superclass = null;
            }
        }
    }
    throw new NoSuchFieldException(fieldName);
}

From source file:Main.java

/**
 * Convenience method to obtain the Swing class from which this
 * component was directly or indirectly derived.
 *
 * @param component The component whose Swing superclass is to be
 * determined/*from  w w w . jav a  2  s. com*/
 * @return The nearest Swing class in the inheritance tree
 */
public static <T extends JComponent> Class getJClass(T component) {
    Class<?> clazz = component.getClass();
    while (!clazz.getName().matches("javax.swing.J[^.]*$")) {
        clazz = clazz.getSuperclass();
    }
    return clazz;
}

From source file:Main.java

private static boolean isAssignableFrom(Class<?> clazz, Class<?> iClazz) {
    if (iClazz.isAssignableFrom(clazz)) {
        return true;
    } else if (clazz.getSuperclass() != null) {
        if (iClazz.isAssignableFrom(clazz.getSuperclass())) {
            return true;
        } else {/*from  w ww .j  ava  2 s .  c  o  m*/
            return isAssignableFrom(clazz.getSuperclass(), iClazz);
        }
    } else {
        return false;
    }
}

From source file:Main.java

/**
 * Returns a list of classes containing the class of the object and all its super classes
 * /*from w  ww  .  j  a  v a  2  s .  com*/
 * @author Tristan Bepler
 */
private static List<Class<?>> getSupers(Object o) {
    List<Class<?>> classes = new ArrayList<Class<?>>();
    Class<?> curClass = o.getClass();
    while (curClass != null) {
        classes.add(curClass);
        curClass = curClass.getSuperclass();
    }
    return classes;
}

From source file:Main.java

public static Class getRemoteViewsClass(Class<? extends RemoteViews> clazz) {
    if (clazz.equals(RemoteViews.class))
        return clazz;
    Class superClass = clazz.getSuperclass();
    while (!superClass.equals(RemoteViews.class)) {
        superClass = superClass.getSuperclass();
    }/* ww  w.ja  va  2s  .co  m*/
    return superClass;
}

From source file:Main.java

public static List<Field> getDeclaredFields(Class<?> cls) {
    List<Field> list = new ArrayList<>();
    list.addAll(Arrays.asList(cls.getDeclaredFields()));
    if (!cls.getSuperclass().getName().equals(Object.class.getName())) {
        list.addAll(getDeclaredFields(cls.getSuperclass()));
    }//from   www  .  j  ava 2s.c om
    return list;
}

From source file:com.wavemaker.tools.apidocs.tools.parser.util.Utils.java

public static List<Class<?>> getAllFilteredSuperTypes(Class<?> type) {
    List<Class<?>> superTypes = new LinkedList<>();
    if (type.getSuperclass() != null) {
        // All classes in java overrides Object, we need to ignore it to avoid making all models as Composed.
        if (!type.getSuperclass().equals(Object.class)) {
            if (ContextUtil.getConfiguration().getModelScanner().filter(type.getSuperclass())) {
                superTypes.add(type.getSuperclass());
            }/*from  w  ww. j a  v a 2s. c o  m*/
        }
    }
    return superTypes;
}