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:com.wsun.seap.common.utils.ReflectionsUtil.java

public static Class<?> getUserClass(Object instance) {
    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;
        }//from   w w w. j  av a 2s. c  o  m
    }
    return clazz;

}

From source file:com.base.dao.sql.ReflectionUtils.java

public static long longValue(Object value) throws NumberFormatException {
    if (value == null)
        return 0L;
    Class c = value.getClass();
    if (c.getSuperclass() == Number.class)
        return ((Number) value).longValue();
    if (c == Boolean.class)
        return ((Boolean) value).booleanValue() ? 1 : 0;
    if (c == Character.class)
        return ((Character) value).charValue();
    return Long.parseLong(stringValue(value, true));
}

From source file:$.Reflections.java

public static Class<?> getUserClass(Object instance) {
        Assert.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  ww .j  a v a2s .  c o m
        }
        return clazz;

    }

From source file:Main.java

public static Type[] getGenericType(Class<?> clazz, Class<?> interfaceClazz) {
    Type st = clazz.getGenericSuperclass();
    Type[] ret = getActualTypeArguments(interfaceClazz, st);

    if (ret != null)
        return ret;

    for (Type t : clazz.getGenericInterfaces()) {
        ret = getActualTypeArguments(interfaceClazz, t);
        if (ret != null)
            return ret;
    }//www .java2 s  .c o m

    Class<?> s = clazz.getSuperclass();
    if (s == null || clazz.equals(s.getClass()))
        return new Type[0];

    return getGenericType(s, interfaceClazz);
}

From source file:com.common.poi.excel.util.Reflections.java

public static Class<?> getUserClass(Object instance) {
    //Validate.notEmpty(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;
        }/*from  w  w  w . ja  v a2  s. c  o  m*/
    }
    return clazz;

}

From source file:com.agama.common.utils.Reflections.java

public static Class<?> getUserClass(Object instance) {

    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;
        }/*from   w ww.j a v a 2s. c o m*/
    }
    return clazz;

}

From source file:com.base.dao.sql.ReflectionUtils.java

public static double doubleValue(Object value) throws NumberFormatException {
    if (value == null)
        return 0.0;
    Class c = value.getClass();
    if (c.getSuperclass() == Number.class) {
        double f1 = processDecimal(value);
        return f1;
    }//from  www .j a v a 2  s. co m
    if (c == Boolean.class)
        return ((Boolean) value).booleanValue() ? 1 : 0;
    if (c == Character.class)
        return ((Character) value).charValue();
    String s = stringValue(value, true);

    return (s.length() == 0) ? 0.0 : Double.parseDouble(s);
}

From source file:com.l2jfree.util.Introspection.java

/**
 * Returns the complete status of the given object in a multi-line string. <BR>
 * <BR>/*from w  w w.  ja  v a 2 s.c  o  m*/
 * The beginning and the end of the string are separated with '=' lines. First, the object's own
 * class is reported in a canonical form and all non-static object's own class fields are
 * reported in name = value pairs. The value is reported using {@link String#valueOf(Object)}
 * except if {@code o == Object}, when 'this' is reported instead. Then, the same is done for
 * each superclass in the class hierarchy. Superclass info is separated by a line of '-'s before
 * the line with the canonical name. <BR>
 * <BR>
 * An example output could be:<BR>
 * <CODE>
 * =================================================<BR>
 * Object's class: com.l2jfree.model.SomeClass<BR>
 * number = 15<BR>
 * object = this<BR>
 * -------------------------------------------------<BR>
 * Superclass: com.l2jfree.model.IntrospectiveObject<BR>
 * -------------------------------------------------<BR>
 * Superclass: java.lang.Object<BR>
 * =================================================<BR>
 * </CODE>
 * 
 * @param o an object
 * @return a textual representation of the given object
 */
public static String toMultiLineString(Object o) {
    String eol = System.getProperty("line.separator");
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < DEFAULT_WIDTH; i++)
        sb.append('=');
    sb.append(eol);

    Class<?> c = o.getClass();
    sb.append("Object's class: ");
    sb.append(c.getCanonicalName());
    sb.append(eol);

    writeFields(c, o, sb, eol, true);

    while ((c = c.getSuperclass()) != null) {
        for (int i = 0; i < DEFAULT_WIDTH; i++)
            sb.append('-');
        sb.append(eol);

        sb.append("Superclass: ");
        sb.append(c.getCanonicalName());
        sb.append(eol);

        writeFields(c, o, sb, eol, true);
    }

    for (int i = 0; i < DEFAULT_WIDTH; i++)
        sb.append('=');
    return sb.toString();
}

From source file:Main.java

public static boolean isSubclassOf(Class<?> type, Class<?> superClass) {
    //        if (type.getSuperclass() != null) {
    ////            if (type.getSuperclass().equals(superClass)) {
    ////                return true;
    ////            }
    ///*from  w ww  .  ja  v  a2 s .c  o m*/
    //            return type.getSuperclass().equals(superClass) || isSubclassOf(type.getSuperclass(), superClass);
    //        }
    //
    //        return false;
    return type.getSuperclass() != null
            && (type.getSuperclass().equals(superClass) || isSubclassOf(type.getSuperclass(), superClass));
}

From source file:br.gov.frameworkdemoiselle.internal.interceptor.AuditableInterceptor.java

public static Class<?> getTargetType(Class<?> type) {
    if (!CoreBootstrap.isAnnotatedType(type)) {
        type = type.getSuperclass();
    }//from   ww  w .j  a v a2 s  . c  o  m
    return type;
}