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

How to use
getEnclosingClass
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getEnclosingClass (Showing top 20 results out of 5,157)

origin: spring-projects/spring-framework

@Override
public boolean hasEnclosingClass() {
  return (this.introspectedClass.getEnclosingClass() != null);
}
origin: org.apache.commons/commons-lang3

/**
 * <p>Is the specified class an inner class or static nested class.</p>
 *
 * @param cls  the class to check, may be null
 * @return {@code true} if the class is an inner or static nested class,
 *  false if not or {@code null}
 */
public static boolean isInnerClass(final Class<?> cls) {
  return cls != null && cls.getEnclosingClass() != null;
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String getEnclosingClassName() {
  Class<?> enclosingClass = this.introspectedClass.getEnclosingClass();
  return (enclosingClass != null ? enclosingClass.getName() : null);
}
origin: org.mockito/mockito-core

private static boolean typeIsNonStaticInnerClass(Class<?> type, int modifiers) {
  return !Modifier.isStatic(modifiers) && type.getEnclosingClass() != null;
}
origin: org.mockito/mockito-core

private static boolean typeIsPrivateAbstractInnerClass(Class<?> type, int modifiers) {
  return Modifier.isPrivate(modifiers) && Modifier.isAbstract(modifiers) && type.getEnclosingClass() != null;
}
origin: google/guava

 @Override
 @Nullable
 Class<?> getOwnerType(Class<?> rawType) {
  return rawType.getEnclosingClass();
 }
},
origin: google/guava

 @Override
 @Nullable
 Class<?> getOwnerType(Class<?> rawType) {
  if (rawType.isLocalClass()) {
   return null;
  } else {
   return rawType.getEnclosingClass();
  }
 }
};
origin: google/guava

/**
 * Returns the owner type of a {@link ParameterizedType} or enclosing class of a {@link Class}, or
 * null otherwise.
 */
private @Nullable Type getOwnerTypeIfPresent() {
 if (runtimeType instanceof ParameterizedType) {
  return ((ParameterizedType) runtimeType).getOwnerType();
 } else if (runtimeType instanceof Class<?>) {
  return ((Class<?>) runtimeType).getEnclosingClass();
 } else {
  return null;
 }
}
origin: junit-team/junit4

private Class<?> getEnclosingClassForNonStaticMemberClass(Class<?> currentTestClass) {
  if (currentTestClass.isMemberClass() && !Modifier.isStatic(currentTestClass.getModifiers())) {
    return currentTestClass.getEnclosingClass();
  } else {
    return null;
  }
}
origin: stackoverflow.com

 Class<?> enclosingClass = getClass().getEnclosingClass();
if (enclosingClass != null) {
 System.out.println(enclosingClass.getName());
} else {
 System.out.println(getClass().getName());
}
origin: google/guava

/**
 * Verifies that {@code ctor} produces a {@link NullPointerException} or {@link
 * UnsupportedOperationException} whenever <i>any</i> of its non-nullable parameters are null.
 */
public void testConstructor(Constructor<?> ctor) {
 Class<?> declaringClass = ctor.getDeclaringClass();
 checkArgument(
   Modifier.isStatic(declaringClass.getModifiers())
     || declaringClass.getEnclosingClass() == null,
   "Cannot test constructor of non-static inner class: %s",
   declaringClass.getName());
 Class<?>[] types = ctor.getParameterTypes();
 for (int nullIndex = 0; nullIndex < types.length; nullIndex++) {
  testConstructorParameter(ctor, nullIndex);
 }
}
origin: google/guava

@Override
Type[] getGenericParameterTypes() {
 Type[] types = constructor.getGenericParameterTypes();
 if (types.length > 0 && mayNeedHiddenThis()) {
  Class<?>[] rawParamTypes = constructor.getParameterTypes();
  if (types.length == rawParamTypes.length
    && rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) {
   // first parameter is the hidden 'this'
   return Arrays.copyOfRange(types, 1, types.length);
  }
 }
 return types;
}
origin: eclipse-vertx/vert.x

/**
 * @deprecated see https://github.com/eclipse-vertx/vert.x/issues/2774
 */
@Deprecated
public static Logger getLogger(final Class<?> clazz) {
 String name = clazz.isAnonymousClass() ?
  clazz.getEnclosingClass().getCanonicalName() :
  clazz.getCanonicalName();
 return getLogger(name);
}
origin: prestodb/presto

 @NullableDecl
 @Override
 Class<?> getOwnerType(Class<?> rawType) {
  return rawType.getEnclosingClass();
 }
},
origin: prestodb/presto

 @NullableDecl
 @Override
 Class<?> getOwnerType(Class<?> rawType) {
  if (rawType.isLocalClass()) {
   return null;
  } else {
   return rawType.getEnclosingClass();
  }
 }
};
origin: prestodb/presto

/**
 * @since 2.7
 */
public static Class<?> getEnclosingClass(Class<?> cls) {
  // Caching does not seem worthwhile, as per profiling
  return isObjectOrPrimitive(cls) ? null : cls.getEnclosingClass();
}
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public TypeDescription getEnclosingType() {
  Class<?> enclosingType = type.getEnclosingClass();
  return enclosingType == null
      ? TypeDescription.UNDEFINED
      : ForLoadedType.of(enclosingType);
}
origin: google/guava

 private boolean mayNeedHiddenThis() {
  Class<?> declaringClass = constructor.getDeclaringClass();
  if (declaringClass.getEnclosingConstructor() != null) {
   // Enclosed in a constructor, needs hidden this
   return true;
  }
  Method enclosingMethod = declaringClass.getEnclosingMethod();
  if (enclosingMethod != null) {
   // Enclosed in a method, if it's not static, must need hidden this.
   return !Modifier.isStatic(enclosingMethod.getModifiers());
  } else {
   // Strictly, this doesn't necessarily indicate a hidden 'this' in the case of
   // static initializer. But there seems no way to tell in that case. :(
   // This may cause issues when an anonymous class is created inside a static initializer,
   // and the class's constructor's first parameter happens to be the enclosing class.
   // In such case, we may mistakenly think that the class is within a non-static context
   // and the first parameter is the hidden 'this'.
   return declaringClass.getEnclosingClass() != null
     && !Modifier.isStatic(declaringClass.getModifiers());
  }
 }
}
origin: square/retrofit

ParameterizedTypeImpl(@Nullable Type ownerType, Type rawType, Type... typeArguments) {
 // Require an owner type if the raw type needs it.
 if (rawType instanceof Class<?>
   && (ownerType == null) != (((Class<?>) rawType).getEnclosingClass() == null)) {
  throw new IllegalArgumentException();
 }
 for (Type typeArgument : typeArguments) {
  checkNotNull(typeArgument, "typeArgument == null");
  checkNotPrimitive(typeArgument);
 }
 this.ownerType = ownerType;
 this.rawType = rawType;
 this.typeArguments = typeArguments.clone();
}
origin: google/guava

/**
 * Returns a type where {@code rawType} is parameterized by {@code arguments} and is owned by
 * {@code ownerType}.
 */
static ParameterizedType newParameterizedTypeWithOwner(
  @Nullable Type ownerType, Class<?> rawType, Type... arguments) {
 if (ownerType == null) {
  return newParameterizedType(rawType, arguments);
 }
 // ParameterizedTypeImpl constructor already checks, but we want to throw NPE before IAE
 checkNotNull(arguments);
 checkArgument(rawType.getEnclosingClass() != null, "Owner type for unenclosed %s", rawType);
 return new ParameterizedTypeImpl(ownerType, rawType, arguments);
}
java.langClassgetEnclosingClass

Javadoc

Returns the enclosing Class of this Class. If there is no enclosing class the method returns null.

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
    Finds a resource with a given name. The rules for searching resources associated with a given class
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • 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
  • Top PhpStorm plugins
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