### Question:
IntrospectUtil { public static boolean hasAttachmentTypeRef(Class<?> type, Set<String> typeNameSet) { if (type == null || typeNameSet.contains(type.getName())) { return false; } typeNameSet.add(type.getName()); if (type == Void.TYPE || type.isPrimitive()) { return false; } else if (type.isArray()) { return hasAttachmentTypeRef(type.getComponentType(), typeNameSet); } else if (javax.activation.DataHandler.class.isAssignableFrom(type)) { return true; } else if (type.getPackage() != null && type.getPackage().getName().startsWith("java")) { return false; } else { boolean hasAttachmentType = false; Method[] allMethods = type.getMethods(); for (Method method : allMethods) { Type genReturnType = method.getGenericReturnType(); Type[] genParamTypes = method.getGenericParameterTypes(); Type[] methodInOutTypes = new Type[genParamTypes.length + 1]; methodInOutTypes[0] = genReturnType; System.arraycopy(genParamTypes, 0, methodInOutTypes, 1, genParamTypes.length); for (Type inOutType : methodInOutTypes) { if (!isParameterizedType(inOutType) && (inOutType instanceof Class)) { hasAttachmentType = hasAttachmentTypeRef((Class<?>) inOutType, typeNameSet); if (hasAttachmentType) { return true; } } else { List<Class<?>> actualTypes = new ArrayList<Class<?>>(2); actualTypes = getAllActualTypes(inOutType, actualTypes); for (Class<?> typeClass : actualTypes) { hasAttachmentType = hasAttachmentTypeRef(typeClass, typeNameSet); if (hasAttachmentType) { return true; } } } } } Field[] publicFields = type.getFields(); for (Field field : publicFields) { Type genType = field.getGenericType(); if (!isParameterizedType(genType)) { hasAttachmentType = hasAttachmentTypeRef((Class<?>) genType, typeNameSet); if (hasAttachmentType) { return true; } } else { List<Class<?>> allTypes = new ArrayList<Class<?>>(2); allTypes = getAllActualTypes(field.getGenericType(), allTypes); for (Class<?> typeClass : allTypes) { hasAttachmentType = hasAttachmentTypeRef(typeClass, typeNameSet); if (hasAttachmentType) { return true; } } } } return false; } }  static Class<?> getWrapperType(String primitiveType); static JTypeTable initializeJType(String fullyQualifiedClassName); static JTypeTable initializeAsyncInterfaceJType(String fullyQualifiedClassName); static void addAllTypesReferred(Class<?> type, Set<String> typeNameSet); static boolean hasAttachmentTypeRef(Class<?> type, Set<String> typeNameSet); static boolean isParameterizedType(Type type); static boolean isWildCardType(Type type); static boolean isGenericArrayType(Type type); static Method getMethodWithSignature(
				Class<?> clazz, 
				String methodName, 
				Class<?>[] params); static boolean hasCollectionType(Class<?>[] types); static boolean isCollectionType(Class<?> typeClazz); static Class<?> loadClass(String fullyQualifiedClassName); static Method[] getPublicInstanceMethods(Class<?> clazz); static Method[] getMatchedMethods(Class<?> clazz, Set<String> methodNameSet); static boolean isPublicInstanceMethod(Method method); static List<Method> getMethods(Class<?> clazz);  }### Answer:
@Test public void hasAttachmentTypeRef2() throws Exception { Class<?> type = String.class; Set<String> typeNameSet = new HashSet<String>(); boolean hasAttachmentType = IntrospectUtil.hasAttachmentTypeRef(type, typeNameSet); assertTrue((hasAttachmentType == false)); }
@Test public void hasAttachmentTypeRef3() throws Exception { boolean hasAttachmentType = false; Class<?> type = CodeGenTestMessage.class; Set<String> typeNameSet = new HashSet<String>(); hasAttachmentType = IntrospectUtil.hasAttachmentTypeRef(type, typeNameSet); assertTrue((hasAttachmentType == true)); }
@Test public void hasAttachmentTypeRef1() throws Exception { Class<?> type = null; Set<String> typeNameSet = new HashSet<String>(); Assert.assertFalse(IntrospectUtil.hasAttachmentTypeRef(type, typeNameSet)); }