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; }
/** * Find all buildable descendant equivalents of a property. * * @param property * @return */ public static Set<JavaProperty> getPropertyBuildableAncestors(JavaProperty property) { Set<JavaProperty> result = new LinkedHashSet<JavaProperty>(); JavaType baseType = property.getType(); if (baseType.isCollection()) { JavaType candidate = TypeAs.UNWRAP_COLLECTION_OF.apply(baseType); for (JavaType descendant : BuilderUtils.getBuildableDescendants(candidate)) { JavaType collectionType = new JavaTypeBuilder(baseType).withGenericTypes(new JavaType[] {descendant}).build(); String propertyName = deCaptializeFirst(descendant.getSimpleName()) + property.getNameCapitalized(); result.add( new JavaPropertyBuilder(property) .withName(propertyName) .withType(collectionType) .addToAttributes(DESCENDANT_OF, property) .addToAttributes(BUILDABLE, true) .build()); } } else { for (JavaType descendant : BuilderUtils.getBuildableDescendants(baseType)) { String propertyName = descendant.getSimpleName() + property.getNameCapitalized(); result.add( new JavaPropertyBuilder(property) .withName(propertyName) .withType(descendant) .addToAttributes(DESCENDANT_OF, property) .addToAttributes(BUILDABLE, true) .build()); } } return result; }
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; }