Java tutorial
//package org.t2framework.commons.util; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** * * <#if locale="en"> * <p> * Modifier check utility. * </p> * <#else> * <p> * </p> * </#if> * * @author shot * */ public class ModifierUtil { public static boolean isAbstract(Member member) { return Modifier.isAbstract(member.getModifiers()); } public static boolean isAbstract(Class<?> clazz) { return Modifier.isAbstract(clazz.getModifiers()); } public static boolean isFinal(Member member) { return Modifier.isFinal(member.getModifiers()); } public static boolean isFinal(Class<?> clazz) { return Modifier.isFinal(clazz.getModifiers()); } public static boolean isInterface(Member member) { return Modifier.isInterface(member.getModifiers()); } public static boolean isInterface(Class<?> clazz) { return Modifier.isInterface(clazz.getModifiers()); } public static boolean isNative(Member member) { return Modifier.isNative(member.getModifiers()); } public static boolean isPrivate(Member member) { return Modifier.isPrivate(member.getModifiers()); } public static boolean isPrivate(Class<?> clazz) { return Modifier.isPrivate(clazz.getModifiers()); } public static boolean isProtected(Member member) { return Modifier.isProtected(member.getModifiers()); } public static boolean isProtected(Class<?> clazz) { return Modifier.isProtected(clazz.getModifiers()); } public static boolean isPublic(Member member) { return Modifier.isPublic(member.getModifiers()); } public static boolean isPublic(Class<?> clazz) { return Modifier.isPublic(clazz.getModifiers()); } public static boolean isStatic(Member member) { return Modifier.isStatic(member.getModifiers()); } public static boolean isStatic(Class<?> clazz) { return Modifier.isStatic(clazz.getModifiers()); } public static boolean isStrict(Member member) { return Modifier.isStrict(member.getModifiers()); } public static boolean isSynchronized(Member member) { return Modifier.isSynchronized(member.getModifiers()); } public static boolean isTransient(Member member) { return Modifier.isTransient(member.getModifiers()); } public static boolean isVolatile(Member member) { return Modifier.isVolatile(member.getModifiers()); } public static boolean isBridge(Member member) { if (member instanceof Method) { return Method.class.cast(member).isBridge(); } else { return false; } } @SuppressWarnings("unchecked") public static boolean isVarArgs(Member member) { if (member instanceof Method) { return Method.class.cast(member).isVarArgs(); } else if (member instanceof Constructor) { return Constructor.class.cast(member).isVarArgs(); } else { return false; } } public static boolean isSynthetic(Member member) { return member.isSynthetic(); } public static boolean isEnumConstant(Member member) { if (member instanceof Field) { return Field.class.cast(member).isEnumConstant(); } else { return false; } } }