public static String matchDeclaringTypeName(JavaType sourceType) { Type candidateType = matchDeclaringType(sourceType); if (candidateType instanceof TypeNameWrapper) { return TypeNameWrapper.class.cast(candidateType).getTypeName(); } Class rawType = ReflectUtil.getRawClass(candidateType); return rawType.getName(); }
public static boolean matchFieldMethods(Type candidate, Collection<JavaMethod> methods) { if (candidate instanceof TypeNameWrapper) { return true; } Class rawClass = ReflectUtil.getRawClass(candidate); JavaType candidateType = new ClassTypeProvider(rawClass).get(); Set<String> candidateMethods = new HashSet<String>(); for (JavaMethod method : candidateType.getMethods()) { candidateMethods.add(method.getName()); } for (JavaMethod method : methods) { String methodName = method.getName(); if (methodName.length() > 3 && (methodName.startsWith("get") || methodName.startsWith("is"))) { if (!candidateMethods.contains(methodName)) { return false; } } } return true; }
public static JavaMethod matchFirstFieldByType(Type ownerType, Type matchingType) { Class rawOwnerType = ReflectUtil.getRawClass(ownerType); JavaType javaOwnerType = new ClassTypeProvider(rawOwnerType).get(); return matchFirstAccessorByType(javaOwnerType, matchingType); }