List of usage examples for java.lang.reflect Modifier isFinal
public static boolean isFinal(int mod)
From source file:Main.java
public static void main(String[] args) throws Exception { Class<?> clazz = String.class; int modifier = clazz.getModifiers(); if (Modifier.isFinal(modifier)) { System.out.println("isFinal"); }/*from w w w . j av a2 s . c om*/ }
From source file:Main.java
public static boolean fieldIsInvalid(Field field) { return (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) || field.isSynthetic();/*from www. j a v a 2 s. c om*/ }
From source file:Main.java
private static void getClassModifier(Class clazz) { int modifier = clazz.getModifiers(); if (Modifier.isFinal(modifier)) { System.out.println(clazz.getName() + " class modifier is final"); }/*from ww w. j a va2 s.c o m*/ }
From source file:Main.java
public static <C> C cloneObject(C original) { try {// ww w . j a v a2 s.c o m C clone = (C) original.getClass().newInstance(); for (Field field : getAllFieldsValues(original.getClass())) { field.setAccessible(true); if (field.get(original) == null || Modifier.isFinal(field.getModifiers())) { continue; } if (field.getType().isPrimitive() || field.getType().equals(String.class) || field.getType().getSuperclass().equals(Number.class) || field.getType().equals(Boolean.class)) { field.set(clone, field.get(original)); } else { Object childObj = field.get(original); if (childObj == original) { field.set(clone, clone); } else { field.set(clone, cloneObject(field.get(original))); } } } return clone; } catch (Exception e) { return null; } }
From source file:Main.java
private static void init() { try {/*from ww w . j a va2s . co m*/ // read all com.android.internal.R Class clazz = Class.forName("com.android.internal.R$layout"); Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { // public static final if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) { try { int id = field.getInt(null); sSystemLayoutResIds.put(id, field.getName()); } catch (IllegalAccessException e) { } } } } catch (Exception e) { } }
From source file:ModifierUtil.java
public static boolean isFinal(Member member) { return Modifier.isFinal(member.getModifiers()); }
From source file:DeclarationInfoDemo.java
public static void printModifiers(final Class dataType) { final int modifiers = dataType.getModifiers(); if (Modifier.isPrivate(modifiers)) { System.out.print("private "); }/*from w ww . j a va2 s .c o m*/ if (Modifier.isPrivate(modifiers)) { System.out.print("private "); } if (Modifier.isPublic(modifiers)) { System.out.print("private "); } if (Modifier.isAbstract(modifiers)) { System.out.print("abstract "); } if (Modifier.isFinal(modifiers)) { System.out.print("final "); } if (Modifier.isNative(modifiers)) { System.out.print("native "); } if (Modifier.isInterface(modifiers)) { System.out.print("interface "); } if (Modifier.isStatic(modifiers)) { System.out.print("static "); } if (Modifier.isStrict(modifiers)) { System.out.print("strict "); } if (Modifier.isSynchronized(modifiers)) { System.out.print("synchronized "); } if (Modifier.isTransient(modifiers)) { System.out.print("transient "); } if (Modifier.isVolatile(modifiers)) { System.out.print("volatile "); } System.out.println(dataType.getName()); }
From source file:Main.java
public static boolean isStaticVariableField(Field field) { final int mod = field.getModifiers(); return Modifier.isStatic(mod) && !Modifier.isFinal(mod); }
From source file:Main.java
public static boolean isInstanceVariableField(Field field) { final int mod = field.getModifiers(); return !Modifier.isStatic(mod) && !Modifier.isFinal(mod); }
From source file:ModifierUtil.java
public static boolean isFinal(Class<?> clazz) { return Modifier.isFinal(clazz.getModifiers()); }