public static JavaMethod findBuildableConstructor(JavaClazz clazz) { for (JavaMethod candidate : clazz.getConstructors()) { if (candidate.getArguments().length != 0) { return candidate; } } return clazz.getConstructors().iterator().next(); }
/** * 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; }
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; }
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; }