Java examples for Reflection:Getter
is getter Method
//package com.java2s; import java.lang.reflect.Method; public class Main { public static final int SET_START = "set".length(); public static final int IS_START = "is".length(); public static boolean isGetter(Method method) { String name = method.getName(); boolean hasNoParam = method.getParameterTypes().length == 0; boolean startsWithGet = (name.length() > SET_START) && name.startsWith("get"); boolean startsWithIs = (name.length() > IS_START) && name.startsWith("is"); return hasNoParam && (startsWithGet || startsWithIs); }/* w w w. j a v a2 s .c o m*/ }