public static Method getPropertyGetter(Class<?> type, String propertyName)
     throws NoSuchMethodException {
   if (isPropertyIsGetter(type, propertyName)) {
     return type.getMethod("is" + ObjectHelper.capitalize(propertyName));
   } else {
     return type.getMethod("get" + ObjectHelper.capitalize(propertyName));
   }
 }
  public static Set<Method> findSetterMethods(
      Class<?> clazz, String name, boolean allowBuilderPattern) {
    Set<Method> candidates = new LinkedHashSet<Method>();

    // Build the method name.
    name = "set" + ObjectHelper.capitalize(name);
    while (clazz != Object.class) {
      // Since Object.class.isInstance all the objects,
      // here we just make sure it will be add to the bottom of the set.
      Method objectSetMethod = null;
      Method[] methods = clazz.getMethods();
      for (Method method : methods) {
        if (method.getName().equals(name) && isSetter(method, allowBuilderPattern)) {
          Class<?> params[] = method.getParameterTypes();
          if (params[0].equals(Object.class)) {
            objectSetMethod = method;
          } else {
            candidates.add(method);
          }
        }
      }
      if (objectSetMethod != null) {
        candidates.add(objectSetMethod);
      }
      clazz = clazz.getSuperclass();
    }
    return candidates;
  }
 public static Method getPropertySetter(Class<?> type, String propertyName)
     throws NoSuchMethodException {
   String name = "set" + ObjectHelper.capitalize(propertyName);
   for (Method method : type.getMethods()) {
     if (isSetter(method) && method.getName().equals(name)) {
       return method;
     }
   }
   throw new NoSuchMethodException(type.getCanonicalName() + "." + name);
 }
 public static boolean isPropertyIsGetter(Class<?> type, String propertyName) {
   try {
     Method method = type.getMethod("is" + ObjectHelper.capitalize(propertyName));
     if (method != null) {
       return method.getReturnType().isAssignableFrom(boolean.class)
           || method.getReturnType().isAssignableFrom(Boolean.class);
     }
   } catch (NoSuchMethodException e) {
     // ignore
   }
   return false;
 }