Java examples for Reflection:Method
is Accessor Method
//package com.java2s; import java.lang.reflect.Method; public class Main { public static final String[] ACCESSOR_PREFIXES = new String[] { "is", "get", "has" }; public static boolean isAccessor(Method method) { for (String prefix : ACCESSOR_PREFIXES) { if (method.getName().startsWith(prefix) && method.getParameterTypes().length == 0 && method.getReturnType() != null) return true; }//from w w w. ja va2 s. co m return false; } }