When reading collections, determine the collection component type.

@param method
@return
557024
private static Class<?> findTargetComponentType(final Method method) {
        final Class<?> returnType = method.getReturnType();
        if (returnType.isArray()) {
            return method.getReturnType().getComponentType();
        }

        if (!(List.class.equals(returnType) || (Map.class.equals(returnType)) || XBAutoMap.class.isAssignableFrom(returnType) || XBAutoList.class.equals(returnType) || XBAutoValue.class.equals(returnType) || ReflectionHelper.isStreamClass(returnType))) {
            return null;
        }
        final Type type = method.getGenericReturnType();
        if (!(type instanceof ParameterizedType) || (((ParameterizedType) type).getActualTypeArguments() == null) || (((ParameterizedType) type).getActualTypeArguments().length < 1)) {
            throw new IllegalArgumentException("When using List as return type for method " + method + ", please specify a generic type for the List. Otherwise I do not know which type I should fill the List with.");
        }
        int index = Map.class.equals(returnType) ? 1 : 0;

        assert index < ((ParameterizedType) type).getActualTypeArguments().length;
        Type componentType = ((ParameterizedType) type).getActualTypeArguments()[index];
        if (!(componentType instanceof Class)) {
            throw new IllegalArgumentException("I don't know how to instantiate the generic type for the return type of method " + method);
        }
        return (Class<?>) componentType;
    }
666326
private static List<Annotation> getAnnotations(Method method) {
		if (methodAnnotationCache.containsKey(method)) {
			return methodAnnotationCache.get(method);
		}
		List<Annotation> annotations = new ArrayList<>();
		Collections.addAll(annotations, method.getAnnotations());
		annotations = Collections.unmodifiableList(annotations);
		methodAnnotationCache.put(method, annotations);
		return annotations;
	}
459847
private static int getMethodModifiers(ExecutableElement method) {
    int modifiers = ElementUtil.fromModifierSet(method.getModifiers());
    if (method.isVarArgs()) {
      modifiers |= ElementUtil.ACC_VARARGS;
    }
    if (ElementUtil.isSynthetic(method)) {
      modifiers |= ElementUtil.ACC_SYNTHETIC;
    }
    return modifiers;
  }
489981
public static boolean isSetter(Method method) {
        String name = method.getName();
        String[] splitname = StringUtils.splitByCharacterTypeCamelCase(name);
        return method.getReturnType().equals(void.class) && Modifier.isPublic(method.getModifiers())
                && splitname[0].equals(SETTER_PREFIX);
    }
579844
public static Set<Method> getAllMethodsInHierarchy(Method method) {
        LinkedHashSet<Method> allMethods = new LinkedHashSet<>();
        val declaringClass = method.getDeclaringClass();
        return getAllMethodsInHierarchy(allMethods, declaringClass, method);
    }
1279800
private static String getClassMethod(Class clazz, Method method) {
		StringBuilder builder = new StringBuilder();
		builder.append(clazz.getName()).append(".").append(method.getName());
		builder.append("(");
		if (method.getParameterCount() > 0) {
			for (int i = 0; i < method.getParameterCount(); i++) {
				Parameter param = method.getParameters()[i];
				builder.append(param.getType().getSimpleName()).append(" ").append(param.getName());

				if (i + 1 < method.getParameterCount()) {
					builder.append(", ");
				}
			}
		}
		builder.append(")");
		return builder.toString();
	}
407211
Class getMethodMapClass(Method method) {

        Class origMapClass = method.getDeclaringClass();
        Class mapClass = origMapClass;
        while (mapClass != null && !isValidMapClass(mapClass)) {
            mapClass = mapClass.getDeclaringClass();
        }
        if (mapClass == null) {
            mapClass = origMapClass;
        }
        return mapClass;
    }
1096805
private static TypeName annotatedReturnType(ExecutableElement method) {
    TypeMirror returnType = method.getReturnType();
    List<AnnotationSpec> annotations =
        returnType.getAnnotationMirrors().stream()
            .map(AnnotationSpec::get)
            .collect(toList());
    return TypeName.get(returnType).annotated(annotations);
  }
262039
public Coll via(def<R> method) {
                        Aggregation.$(map).forEach((k, v) -> {
                                collection.add(method.apply(k, v));
                        });
                        return collection;
                }
196413
public FieldAccessor create(final Method method) {

        ArgUtils.notNull(method, "method");

        final FieldAccessor accessor = new FieldAccessor();

        final String methodName = method.getName();
        if(ClassUtils.isGetterMethod(method) || ClassUtils.isBooleanGetterMethod(method)) {
            final String propertyName;
            if(methodName.startsWith("get")) {
                propertyName = Utils.uncapitalize(methodName.substring(3));
            } else {
                propertyName = Utils.uncapitalize(methodName.substring(2));
            }

            // 共通情報の設定
            accessor.name = propertyName;
            accessor.targetType = method.getReturnType();
            accessor.declaringClass = method.getDeclaringClass();

            // getter情報の設定
            setupWithGetter(accessor, method);

            // フィールド情報の設定
            ClassUtils.extractField(accessor.getDeclaringClass(), accessor.getName(), accessor.getType())
                    .ifPresent(field -> setupWithFiled(accessor, field));

            // setter情報の設定
            ClassUtils.extractSetter(accessor.getDeclaringClass(), accessor.getName(), accessor.getType())
                    .ifPresent(setter -> setupWithSetter(accessor, setter));

            // コンポーネントタイプの設定
            if(Collection.class.isAssignableFrom(accessor.getType())) {
                ParameterizedType type = (ParameterizedType) method.getGenericReturnType();
                accessor.componentType = Optional.of((Class<?>) type.getActualTypeArguments()[0]);

            } else if(accessor.getType().isArray()) {
                accessor.componentType = Optional.of(accessor.getType().getComponentType());

            } else if(Map.class.isAssignableFrom(accessor.getType())) {
                ParameterizedType type = (ParameterizedType) method.getGenericReturnType();
                accessor.componentType = Optional.of((Class<?>) type.getActualTypeArguments()[1]);
            }

        } else if(ClassUtils.isSetterMethod(method)) {
            final String propertyName = Utils.uncapitalize(methodName.substring(3));

            // 共通情報の設定
            accessor.name = propertyName;
            accessor.targetType = method.getParameterTypes()[0];
            accessor.declaringClass = method.getDeclaringClass();

            // setter情報の設定
            setupWithSetter(accessor, method);

            // フィールド情報の設定
            ClassUtils.extractField(accessor.getDeclaringClass(), accessor.getName(), accessor.getType())
                    .ifPresent(field -> setupWithFiled(accessor, field));

            // getter情報の設定
            if(ClassUtils.isPrimitiveBoolean(accessor.getType())) {
                ClassUtils.extractBooleanGetter(accessor.getDeclaringClass(), accessor.getName())
                        .ifPresent(getter -> setupWithGetter(accessor, getter));

            } else {
                ClassUtils.extractGetter(accessor.getDeclaringClass(), accessor.getName(), accessor.getType())
                        .ifPresent(getter -> setupWithGetter(accessor, getter));
            }

            // コンポーネントタイプの設定
            if(Collection.class.isAssignableFrom(accessor.getType())) {
                ParameterizedType type = (ParameterizedType) method.getGenericParameterTypes()[0];
                accessor.componentType = Optional.of((Class<?>) type.getActualTypeArguments()[0]);

            } else if(accessor.getType().isArray()) {
                accessor.componentType = Optional.of(accessor.getType().getComponentType());

            } else if(Map.class.isAssignableFrom(accessor.getType())) {
                ParameterizedType type = (ParameterizedType) method.getGenericParameterTypes()[0];
                accessor.componentType = Optional.of((Class<?>) type.getActualTypeArguments()[1]);
            }

        } else {
            throw new IllegalArgumentException(MessageBuilder.create("method.noAccessor")
                    .varWithClass("className", method.getDeclaringClass())
                    .var("methodName", methodName)
                    .format());
        }

        // 位置・ラベル情報のアクセッサの設定
        if(accessor.hasAnnotation(XlsMapColumns.class)) {
            accessor.mapPositionSetter = mapPositionSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
            accessor.mapLabelSetter = mapLabelSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());

        } else if(accessor.hasAnnotation(XlsArrayColumns.class)
                || accessor.hasAnnotation(XlsArrayCells.class)
                || accessor.hasAnnotation(XlsLabelledArrayCells.class)
                || accessor.hasAnnotation(XlsIterateTables.class)){
            // リストや配列形式の場合
            accessor.arrayPositionSetter = arrayPositionSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
            accessor.arrayLabelSetter = arrayLabelSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());

            if(accessor.hasAnnotation(XlsArrayColumns.class)
                    || accessor.hasAnnotation(XlsLabelledArrayCells.class)) {
                // インデックスが付いていないラベルの設定
                accessor.labelSetter = labelSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
            }

        } else {
            // XlsMapColumnsを持たない通常のプロパティの場合
            accessor.positionSetter = positionSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
            accessor.positionGetter = positionGetterFactory.create(accessor.getDeclaringClass(), accessor.getName());

            accessor.labelSetter = labelSetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
            accessor.labelGetter = labelGetterFactory.create(accessor.getDeclaringClass(), accessor.getName());
        }


        return accessor;
    }
640766
public static boolean isObjectMethod(Method method) {
		if (method == null) {
			return false;
		}
		try {
			Object.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
			return true;
		}
		catch (Exception ex) {
			return false;
		}
	}
130971
public MethodDoc getMatchingMethod(MethodDoc method) {

        MethodDoc[] methods = getMethods();
        for (int i = 0; i < methods.length; i++) {

            if (method.getName().equals(methods[i].getName()) &&
                method.getSignature().equals(methods[i].getSignature())) {

                return methods[i];
            }
        }
        return null;
    }
365845
function isCollectionMethod(version, method) {
    return methodSupportsShorthand(version, method) || _.includes(expandAliases(version, ['reduce', 'reduceRight']), method)
}
1246994
@Override
	public Collection<HttpMethod> getRequestMethod(Class<?> type, Method method) {

		Assert.notNull(type, "Type must not be null!");
		Assert.notNull(method, "Method must not be null!");

		Annotation mergedAnnotation = findMergedAnnotation(method, annotationType);
		Object value = getValue(mergedAnnotation, "method");

		RequestMethod[] requestMethods = (RequestMethod[]) value;

		if (requestMethods == null) {
			return Collections.emptyList();
		}

		List<HttpMethod> requestMethodNames = new ArrayList<>();

		for (RequestMethod requestMethod : requestMethods) {
			requestMethodNames.add(HttpMethod.valueOf(requestMethod.toString()));
		}

		return requestMethodNames;
	}
874766
public Class<?> getArrayOrCollectionComponentType() {
        if (!isCollection() && !isArray()) {
            throw new IllegalStateException();
        }

        if (isCollection()) {
            Type type = field.getGenericType();
            if (type instanceof ParameterizedType) {
                return toClass(((ParameterizedType) type).getActualTypeArguments()[0]);
            } else {
                String message = String.format("Cannot determine the type parameter of the collection-typed field %s. Raw types are not supported", field);
                throw new IllegalArgumentException(message);
            }
        } else {
            return field.getType().getComponentType();
        }
    }
62555
public <T> List<T> getComponentInstancesOfType(Class<T> componentType)
   {
      return container.getComponentInstancesOfType(componentType);
   }
399318
@Override
	@Nullable
	public String getMapping(Method method) {

		Assert.notNull(method, "Method must not be null!");
		return getMapping(method.getDeclaringClass(), method);
	}