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

How to use
getModifiers
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getModifiers (Showing top 20 results out of 18,630)

origin: spring-projects/spring-framework

  public int getModifiers() {
    return clazz.getModifiers();
  }
};
origin: spring-projects/spring-framework

public static int findPackageProtected(Class[] classes) {
  for (int i = 0; i < classes.length; i++) {
    if (!Modifier.isPublic(classes[i].getModifiers())) {
      return i;
    }
  }
  return 0;
}
origin: spring-projects/spring-framework

@Override
public boolean isFinal() {
  return Modifier.isFinal(this.introspectedClass.getModifiers());
}
origin: spring-projects/spring-framework

@Override
public boolean isAbstract() {
  return Modifier.isAbstract(this.introspectedClass.getModifiers());
}
origin: spring-projects/spring-framework

/**
 * Determine if the supplied class is an <em>inner class</em>,
 * i.e. a non-static member of an enclosing class.
 * @return {@code true} if the supplied class is an inner class
 * @since 5.0.5
 * @see Class#isMemberClass()
 */
public static boolean isInnerClass(Class<?> clazz) {
  return (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()));
}
origin: spring-projects/spring-framework

@Override
public boolean isCompilable() {
  return (Modifier.isPublic(this.member.getModifiers()) &&
      Modifier.isPublic(this.member.getDeclaringClass().getModifiers()));
}
origin: spring-projects/spring-framework

private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) {
  Assert.notNull(clazz, "Class must not be null");
  int modifiers = clazz.getModifiers();
  return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers));
}
origin: spring-projects/spring-framework

public ReflectiveElementFactory(Class<? extends E> elementClass) {
  Assert.notNull(elementClass, "Element class must not be null");
  Assert.isTrue(!elementClass.isInterface(), "Element class must not be an interface type");
  Assert.isTrue(!Modifier.isAbstract(elementClass.getModifiers()), "Element class cannot be an abstract class");
  this.elementClass = elementClass;
}
origin: spring-projects/spring-framework

private boolean canCreateCopy(Class<?> requiredType) {
  return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) &&
      Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType));
}
origin: spring-projects/spring-framework

/**
 * Make the given constructor accessible, explicitly setting it accessible
 * if necessary. The {@code setAccessible(true)} method is only called
 * when actually necessary, to avoid unnecessary conflicts with a JVM
 * SecurityManager (if active).
 * @param ctor the constructor to make accessible
 * @see java.lang.reflect.Constructor#setAccessible
 */
@SuppressWarnings("deprecation")  // on JDK 9
public static void makeAccessible(Constructor<?> ctor) {
  if ((!Modifier.isPublic(ctor.getModifiers()) ||
      !Modifier.isPublic(ctor.getDeclaringClass().getModifiers())) && !ctor.isAccessible()) {
    ctor.setAccessible(true);
  }
}
origin: google/guava

 @Override
 public boolean apply(Class<?> cls) {
  return visibility.isVisible(cls.getModifiers());
 }
};
origin: spring-projects/spring-framework

/**
 * Make the given method accessible, explicitly setting it accessible if
 * necessary. The {@code setAccessible(true)} method is only called
 * when actually necessary, to avoid unnecessary conflicts with a JVM
 * SecurityManager (if active).
 * @param method the method to make accessible
 * @see java.lang.reflect.Method#setAccessible
 */
@SuppressWarnings("deprecation")  // on JDK 9
public static void makeAccessible(Method method) {
  if ((!Modifier.isPublic(method.getModifiers()) ||
      !Modifier.isPublic(method.getDeclaringClass().getModifiers())) && !method.isAccessible()) {
    method.setAccessible(true);
  }
}
origin: spring-projects/spring-framework

@Override
public boolean isIndependent() {
  return (!hasEnclosingClass() ||
      (this.introspectedClass.getDeclaringClass() != null &&
          Modifier.isStatic(this.introspectedClass.getModifiers())));
}
origin: spring-projects/spring-framework

/**
 * Make the given field accessible, explicitly setting it accessible if
 * necessary. The {@code setAccessible(true)} method is only called
 * when actually necessary, to avoid unnecessary conflicts with a JVM
 * SecurityManager (if active).
 * @param field the field to make accessible
 * @see java.lang.reflect.Field#setAccessible
 */
@SuppressWarnings("deprecation")  // on JDK 9
public static void makeAccessible(Field field) {
  if ((!Modifier.isPublic(field.getModifiers()) ||
      !Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
      Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
    field.setAccessible(true);
  }
}
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: spring-projects/spring-framework

@Nullable
private Class<?> discoverPublicDeclaringClass(Method method, Class<?> clazz) {
  if (Modifier.isPublic(clazz.getModifiers())) {
    try {
      clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
      return clazz;
    }
    catch (NoSuchMethodException ex) {
      // Continue below...
    }
  }
  if (clazz.getSuperclass() != null) {
    return discoverPublicDeclaringClass(method, clazz.getSuperclass());
  }
  return null;
}
origin: spring-projects/spring-framework

@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException {
  ManagedResource ann = AnnotationUtils.findAnnotation(beanClass, ManagedResource.class);
  if (ann == null) {
    return null;
  }
  Class<?> declaringClass = AnnotationUtils.findAnnotationDeclaringClass(ManagedResource.class, beanClass);
  Class<?> target = (declaringClass != null && !declaringClass.isInterface() ? declaringClass : beanClass);
  if (!Modifier.isPublic(target.getModifiers())) {
    throw new InvalidMetadataException("@ManagedResource class '" + target.getName() + "' must be public");
  }
  org.springframework.jmx.export.metadata.ManagedResource managedResource = new org.springframework.jmx.export.metadata.ManagedResource();
  AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource, this.embeddedValueResolver);
  return managedResource;
}
origin: google/guava

@Override
public final boolean isOverridable() {
 return !(isFinal()
   || isPrivate()
   || isStatic()
   || Modifier.isFinal(getDeclaringClass().getModifiers()));
}
origin: google/guava

void doTestNulls(Class<?> cls, Visibility visibility)
  throws ParameterNotInstantiableException, IllegalAccessException, InvocationTargetException,
    FactoryMethodReturnsNullException {
 if (!Modifier.isAbstract(cls.getModifiers())) {
  nullPointerTester.testConstructors(cls, visibility);
 }
 nullPointerTester.testStaticMethods(cls, visibility);
 if (hasInstanceMethodToTestNulls(cls, visibility)) {
  Object instance = instantiate(cls);
  if (instance != null) {
   nullPointerTester.testInstanceMethods(instance, visibility);
  }
 }
}
origin: spring-projects/spring-framework

@Test
public void loadPackagePrivateFactory() {
  List<DummyPackagePrivateFactory> factories =
      SpringFactoriesLoader.loadFactories(DummyPackagePrivateFactory.class, null);
  assertEquals(1, factories.size());
  assertTrue((factories.get(0).getClass().getModifiers() & Modifier.PUBLIC) == 0);
}
java.langClassgetModifiers

Javadoc

Returns an integer that represents the modifiers of the class represented by this Class. The returned value is a combination of bits defined by constants in the Modifier class.

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
  • 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 plugins for Android Studio
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