Example usage for java.lang.reflect Modifier fieldModifiers

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

Introduction

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

Prototype

public static int fieldModifiers() 

Source Link

Document

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

Usage

From source file:Main.java

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

From source file:MySuperClass.java

public static ArrayList<String> getFieldsDesciption(Field[] fields) {
    ArrayList<String> fieldList = new ArrayList<>();

    for (Field f : fields) {
        int mod = f.getModifiers() & Modifier.fieldModifiers();
        String modifiers = Modifier.toString(mod);

        Class<?> type = f.getType();
        String typeName = type.getSimpleName();

        String fieldName = f.getName();

        fieldList.add(modifiers + "  " + typeName + "  " + fieldName);
    }/*from w w  w.  j a  v  a  2 s.c o  m*/

    return fieldList;
}