public static Map<String, Method> getSetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> setMethodMap = new HashMap<>(); Method[] methods = clazz.getMethods(); for (Method method : methods) { method.setAccessible(true); if (Modifier.isStatic(method.getModifiers())) continue; if (Modifier.isAbstract(method.getModifiers())) continue; if (method.getName().length() < 4) continue; if (!method.getName().startsWith("set")) continue; if (!method.getReturnType().equals(Void.TYPE)) continue; if (method.getParameterTypes().length != 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) { setMethodMap.put(propertyName, method); } } return setMethodMap; }
public static Map<String, Method> getSetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> setMethodMap = new HashMap<String, Method>(); Method[] methods = clazz.getMethods(); for (Method method : methods) { method.setAccessible(true); if (method.getName().length() < 4 || !method.getName().startsWith("set") || Modifier.isStatic(method.getModifiers()) || !method.getReturnType().equals(Void.TYPE) || method.getParameterTypes().length != 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) setMethodMap.put(propertyName, method); } return setMethodMap; }
public static Map<String, Method> getSetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> setMethodMap = new HashMap<>(); Method[] methods = clazz.getMethods(); for (Method method : methods) { method.setAccessible(true); if (Modifier.isStatic(method.getModifiers())) continue; if (Modifier.isAbstract(method.getModifiers())) continue; if (method.getName().length() < 4) continue; if (!method.getName().startsWith("set")) continue; if (!method.getReturnType().equals(Void.TYPE)) continue; if (method.getParameterTypes().length != 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) { setMethodMap.put(propertyName, method); } } return setMethodMap; }
public static Map<String, Method> getGetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> getMethodMap = new HashMap<>(); Method[] methods = clazz.getMethods(); for (Method method : methods) { method.setAccessible(true); if (Modifier.isStatic(method.getModifiers())) continue; if (Modifier.isAbstract(method.getModifiers())) continue; if (method.getName().equals("getClass")) continue; if (!(method.getName().startsWith("is") || method.getName().startsWith("get"))) continue; if (method.getParameterTypes().length != 0) continue; if (method.getReturnType() == void.class) continue; String methodName = method.getName(); int index = (methodName.charAt(0) == 'i' ? 2 : 3); if (methodName.length() < index + 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) { getMethodMap.put(propertyName, method); } } return getMethodMap; }
public static Map<String, Method> getGetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> getMethodMap = new HashMap<>(); Method[] methods = clazz.getMethods(); for (Method method : methods) { method.setAccessible(true); if (Modifier.isStatic(method.getModifiers())) continue; if (Modifier.isAbstract(method.getModifiers())) continue; if (method.getName().equals("getClass")) continue; if (!(method.getName().startsWith("is") || method.getName().startsWith("get"))) continue; if (method.getParameterTypes().length != 0) continue; if (method.getReturnType() == void.class) continue; String methodName = method.getName(); int index = (methodName.charAt(0) == 'i' ? 2 : 3); if (methodName.length() < index + 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) { getMethodMap.put(propertyName, method); } } return getMethodMap; }
public static Map<String, Method> getGetterMethods(Class<?> clazz, BeanMethodFilter filter) { Map<String, Method> getMethodMap = new HashMap<String, Method>(); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; method.setAccessible(true); String methodName = method.getName(); if (Modifier.isStatic(method.getModifiers())) continue; if (Modifier.isAbstract(method.getModifiers())) continue; if (method.getName().equals("getClass")) continue; if (!(method.getName().startsWith("is") || method.getName().startsWith("get"))) continue; if (method.getParameterTypes().length != 0) continue; if (method.getReturnType() == void.class) continue; int index = (methodName.charAt(0) == 'i' ? 2 : 3); if (methodName.length() < index + 1) continue; String propertyName = getPropertyName(method); if (filter == null || filter.accept(propertyName, method)) getMethodMap.put(propertyName, method); } return getMethodMap; }