Esempio n. 1
0
 public static JavaMethod findBuildableConstructor(JavaClazz clazz) {
   for (JavaMethod candidate : clazz.getConstructors()) {
     if (candidate.getArguments().length != 0) {
       return candidate;
     }
   }
   return clazz.getConstructors().iterator().next();
 }
Esempio n. 2
0
 /**
  * Checks if there is a default constructor available.
  *
  * @param item The clazz to check.
  * @return
  */
 public static boolean hasDefaultConstructor(JavaClazz item) {
   if (item == null) {
     return false;
   } else if (item.getConstructors().isEmpty()) {
     return true;
   } else {
     for (JavaMethod constructor : item.getConstructors()) {
       if (constructor.getArguments().length == 0) {
         return true;
       }
     }
   }
   return false;
 }
Esempio n. 3
0
  private static boolean isApplicableGetterOf(JavaMethod method, JavaProperty property) {
    if (!method.getReturnType().isAssignable(property.getType())) {
      return false;
    }

    if (method.getName().endsWith("get" + property.getNameCapitalized())) {
      return true;
    }

    if (method.getName().endsWith("is" + property.getNameCapitalized())) {
      return true;
    }
    return false;
  }
Esempio n. 4
0
  public static boolean isInlineable(JavaMethod method) {
    if (method.getArguments().length == 0 || method.getArguments().length > 5) {
      return false;
    }

    for (JavaProperty argument : method.getArguments()) {
      if (StringUtils.isNullOrEmpty(argument.getType().getPackageName())) {
        continue;
      } else if (argument.getType().getPackageName().startsWith("java.lang")) {
        continue;
      } else {
        return false;
      }
    }
    return true;
  }