Example usage for java.lang Class getModifiers

List of usage examples for java.lang Class getModifiers

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public native int getModifiers();

Source Link

Document

Returns the Java language modifiers for this class or interface, encoded in an integer.

Usage

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isAbstract(modifier)) {
        System.out.println(clazz.getName() + " class modifier is abstract");
    }/*from   ww  w .j a v  a  2  s  . c  o m*/
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isPublic(modifier)) {
        System.out.println(clazz.getName() + " class modifier is public");
    }//from w w  w  .  ja  v a  2s .  c  o  m
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isStatic(modifier)) {
        System.out.println(clazz.getName() + " class modifier is static");
    }//w ww.  j a va2 s.  c om

}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isProtected(modifier)) {
        System.out.println(clazz.getName() + " class modifier is protected");
    }//from ww  w . j a va 2s  .  c o  m

}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isPrivate(modifier)) {
        System.out.println(clazz.getName() + " class modifier is private");
    }//from   w w w .  ja v  a  2 s  . co  m

}

From source file:SampleModifier.java

public static void printModifiers(Object o) {
    Class c = o.getClass();
    int m = c.getModifiers();
    if (Modifier.isPublic(m))
        System.out.println("public");
    if (Modifier.isAbstract(m))
        System.out.println("abstract");
    if (Modifier.isFinal(m))
        System.out.println("final");
}

From source file:Main.java

/**
 * Helper method that checks if given class is a concrete one;
 * that is, not an interface or abstract class.
 *///from  ww w  .j  a v a  2s  . c  o  m
public static boolean isConcrete(Class<?> type) {
    int mod = type.getModifiers();
    return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static boolean isAbstractClass(Class clazz) {
    int modifier = clazz.getModifiers();
    return Modifier.isAbstract(modifier) || Modifier.isInterface(modifier);
}

From source file:Main.java

public static boolean isConcrete(Class<?> paramClass) {
    return (0x600 & paramClass.getModifiers()) == 0;
}

From source file:org.openlegacy.utils.ClassUtils.java

public static boolean isAbstract(Class<?> cls) {
    return Modifier.isAbstract(cls.getModifiers());
}