Tabnine Logo
Class.getSuperclass
Code IndexAdd Tabnine to your IDE (free)

How to use
getSuperclass
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getSuperclass (Showing top 20 results out of 1,395)

origin: spring-projects/spring-framework

@Override
public boolean hasSuperClass() {
  return (this.introspectedClass.getSuperclass() != null);
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String getSuperClassName() {
  Class<?> superClass = this.introspectedClass.getSuperclass();
  return (superClass != null ? superClass.getName() : null);
}
origin: apache/incubator-dubbo

public EnumSerializer(Class cl) {
  // hessian/32b[12], hessian/3ab[23]
  if (!cl.isEnum() && cl.getSuperclass().isEnum())
    cl = cl.getSuperclass();
  try {
    _name = cl.getMethod("name", new Class[0]);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-projects/spring-framework

public static Class<?> getEnumType(Class<?> targetType) {
  Class<?> enumType = targetType;
  while (enumType != null && !enumType.isEnum()) {
    enumType = enumType.getSuperclass();
  }
  Assert.notNull(enumType, () -> "The target type " + targetType.getName() + " does not refer to an enum");
  return enumType;
}
origin: spring-projects/spring-framework

public static Method findDeclaredMethod(final Class type,
    final String methodName, final Class[] parameterTypes)
    throws NoSuchMethodException {
  Class cl = type;
  while (cl != null) {
    try {
      return cl.getDeclaredMethod(methodName, parameterTypes);
    }
    catch (NoSuchMethodException e) {
      cl = cl.getSuperclass();
    }
  }
  throw new NoSuchMethodException(methodName);
}
origin: spring-projects/spring-framework

/**
 * Return the user-defined class for the given class: usually simply the given
 * class, but the original class in case of a CGLIB-generated subclass.
 * @param clazz the class to check
 * @return the user-defined class
 */
public static Class<?> getUserClass(Class<?> clazz) {
  if (clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
    Class<?> superclass = clazz.getSuperclass();
    if (superclass != null && superclass != Object.class) {
      return superclass;
    }
  }
  return clazz;
}
origin: apache/incubator-dubbo

/**
 * Returns the writeReplace method
 */
protected Method getWriteReplace(Class cl, Class param) {
  for (; cl != null; cl = cl.getSuperclass()) {
    for (Method method : cl.getDeclaredMethods()) {
      if (method.getName().equals("writeReplace")
          && method.getParameterTypes().length == 1
          && param.equals(method.getParameterTypes()[0]))
        return method;
    }
  }
  return null;
}
origin: apache/incubator-dubbo

/**
 * Returns the writeReplace method
 */
protected Method getWriteReplace(Class cl, Class param) {
  for (; cl != null; cl = cl.getSuperclass()) {
    for (Method method : cl.getDeclaredMethods()) {
      if (method.getName().equals("writeReplace")
          && method.getParameterTypes().length == 1
          && param.equals(method.getParameterTypes()[0]))
        return method;
    }
  }
  return null;
}
origin: google/guava

 @Override
 @Nullable
 Class<?> getSuperclass(Class<?> type) {
  return type.getSuperclass();
 }
};
origin: spring-projects/spring-framework

private static Class<?> findParameterizedTypeReferenceSubclass(Class<?> child) {
  Class<?> parent = child.getSuperclass();
  if (Object.class == parent) {
    throw new IllegalStateException("Expected ParameterizedTypeReference superclass");
  }
  else if (ParameterizedTypeReference.class == parent) {
    return child;
  }
  else {
    return findParameterizedTypeReferenceSubclass(parent);
  }
}
origin: spring-projects/spring-framework

private int getDepth(String exceptionMapping, Class<?> exceptionClass, int depth) {
  if (exceptionClass.getName().contains(exceptionMapping)) {
    // Found it!
    return depth;
  }
  // If we've gone as far as we can go and haven't found it...
  if (exceptionClass == Throwable.class) {
    return -1;
  }
  return getDepth(exceptionMapping, exceptionClass.getSuperclass(), depth + 1);
}
origin: spring-projects/spring-framework

public static List addAllInterfaces(Class type, List list) {
  Class superclass = type.getSuperclass();
  if (superclass != null) {
    list.addAll(Arrays.asList(type.getInterfaces()));
    addAllInterfaces(superclass, list);
  }
  return list;
}
origin: spring-projects/spring-framework

private int getDepth(Class<?> exceptionClass, int depth) {
  if (exceptionClass.getName().contains(this.exceptionName)) {
    // Found it!
    return depth;
  }
  // If we've gone as far as we can go and haven't found it...
  if (exceptionClass == Throwable.class) {
    return -1;
  }
  return getDepth(exceptionClass.getSuperclass(), depth + 1);
}
origin: spring-projects/spring-framework

private int getDepth(Class<?> declaredException, Class<?> exceptionToMatch, int depth) {
  if (exceptionToMatch.equals(declaredException)) {
    // Found it!
    return depth;
  }
  // If we've gone as far as we can go and haven't found it...
  if (exceptionToMatch == Throwable.class) {
    return Integer.MAX_VALUE;
  }
  return getDepth(declaredException, exceptionToMatch.getSuperclass(), depth + 1);
}
origin: spring-projects/spring-framework

@Override
@Nullable
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
  Field field = ReflectionUtils.findField(obj.getClass(), BEAN_FACTORY_FIELD);
  Assert.state(field != null, "Unable to find generated BeanFactory field");
  field.set(obj, args[0]);
  // Does the actual (non-CGLIB) superclass implement BeanFactoryAware?
  // If so, call its setBeanFactory() method. If not, just exit.
  if (BeanFactoryAware.class.isAssignableFrom(ClassUtils.getUserClass(obj.getClass().getSuperclass()))) {
    return proxy.invokeSuper(obj, args);
  }
  return null;
}
origin: spring-projects/spring-framework

  @Override
  public Object postProcessBeforeInitialization(Object bean, String beanName)  {
    if (bean instanceof ImportAware) {
      ImportRegistry ir = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
      AnnotationMetadata importingClass = ir.getImportingClassFor(bean.getClass().getSuperclass().getName());
      if (importingClass != null) {
        ((ImportAware) bean).setImportMetadata(importingClass);
      }
    }
    return bean;
  }
}
origin: google/guava

/** [descendant, ancestor) */
private static Set<Class<?>> getClassesBetween(Class<?> descendant, Class<?> ancestor) {
 Set<Class<?>> classes = newHashSet();
 while (!descendant.equals(ancestor)) {
  classes.add(descendant);
  descendant = descendant.getSuperclass();
 }
 return classes;
}
origin: spring-projects/spring-framework

public SourceClass getSuperClass() throws IOException {
  if (this.source instanceof Class) {
    return asSourceClass(((Class<?>) this.source).getSuperclass());
  }
  return asSourceClass(((MetadataReader) this.source).getClassMetadata().getSuperClassName());
}
origin: google/guava

public void testGetGenericSuperclass_withSuperclass() {
 TypeToken<? super ArrayList<String>> superToken =
   new TypeToken<ArrayList<String>>() {}.getGenericSuperclass();
 assertEquals(ArrayList.class.getSuperclass(), superToken.getRawType());
 assertEquals(
   String.class, ((ParameterizedType) superToken.getType()).getActualTypeArguments()[0]);
 assertEquals(TypeToken.of(Base.class), TypeToken.of(Sub.class).getGenericSuperclass());
 assertEquals(TypeToken.of(Object.class), TypeToken.of(Sub[].class).getGenericSuperclass());
}
origin: google/guava

public <T, T1 extends T> void testAssignableGenericArrayToClass() {
 assertTrue(TypeToken.of(Object[].class.getSuperclass()).isSupertypeOf(new TypeToken<T[]>() {}));
 for (Class<?> interfaceType : Object[].class.getInterfaces()) {
  assertTrue(TypeToken.of(interfaceType).isSupertypeOf(new TypeToken<T[]>() {}));
 }
 assertTrue(TypeToken.of(Object.class).isSupertypeOf(new TypeToken<T[]>() {}));
 assertFalse(TypeToken.of(String.class).isSupertypeOf(new TypeToken<T[]>() {}));
}
java.langClassgetSuperclass

Javadoc

Returns the Class object which represents the superclass of the class represented by this Class. If this Class represents the Object class, a primitive type, an interface or void then the method returns null. If this Class represents an array class then the Object class is returned.

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • getCanonicalName
    Returns the canonical name of the underlying class as defined by the Java Language Specification. Re
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now