Example usage for java.lang.reflect Modifier interfaceModifiers

List of usage examples for java.lang.reflect Modifier interfaceModifiers

Introduction

In this page you can find the example usage for java.lang.reflect Modifier interfaceModifiers.

Prototype

public static int interfaceModifiers() 

Source Link

Document

Return an int value OR-ing together the source language modifiers that can be applied to an interface.

Usage

From source file:Main.java

public static void main(String... args) throws Exception {
    System.out.println(Modifier.toString(Modifier.interfaceModifiers()));
}

From source file:MyClass.java

public static String getClassDescription(Class c) {
    StringBuilder classDesc = new StringBuilder();
    int modifierBits = 0;
    String keyword = "";
    if (c.isInterface()) {
        modifierBits = c.getModifiers() & Modifier.interfaceModifiers();
        if (c.isAnnotation()) {
            keyword = "@interface";
        } else {//from w  w w .jav  a 2s .c  o  m
            keyword = "interface";
        }
    } else if (c.isEnum()) {
        modifierBits = c.getModifiers() & Modifier.classModifiers();
        keyword = "enum";
    }
    modifierBits = c.getModifiers() & Modifier.classModifiers();
    keyword = "class";

    String modifiers = Modifier.toString(modifierBits);
    classDesc.append(modifiers);
    classDesc.append(" " + keyword);
    String simpleName = c.getSimpleName();
    classDesc.append(" " + simpleName);

    String genericParms = getGenericTypeParams(c);
    classDesc.append(genericParms);

    Class superClass = c.getSuperclass();
    if (superClass != null) {
        String superClassSimpleName = superClass.getSimpleName();
        classDesc.append("  extends " + superClassSimpleName);
    }
    String interfaces = Main.getClassInterfaces(c);
    if (interfaces != null) {
        classDesc.append("  implements " + interfaces);
    }
    return classDesc.toString();
}