private AnnotatedValueResolver build() {
            checkArgument(resolver != null, "'resolver' should be specified");

            final boolean isOptional = type == Optional.class;
            final boolean isAnnotatedNullable = isAnnotatedNullable(typeElement);
            final boolean isMarkedNullable = KotlinUtil.isMarkedNullable(typeElement);
            final boolean isNullable = isAnnotatedNullable || isMarkedNullable;
            final Type originalParameterizedType = parameterizedTypeOf(typeElement);
            final Type unwrappedParameterizedType = isOptional ? unwrapOptional(originalParameterizedType)
                                                               : originalParameterizedType;

            // Used only for warning message.
            final String nullableRepresentation =
                    isMarkedNullable && !isAnnotatedNullable ? "?(Kotlin nullable type)"
                                                             : "@Nullable";

            if (isAnnotatedNullable && isMarkedNullable) {
                warnRedundantUse("@Nullable", "?(Kotlin nullable type)");
            }
            if (isOptional && isNullable) {
                warnRedundantUse("Optional", nullableRepresentation);
            }

            final boolean shouldExist;
            final String defaultValue;

            final Default aDefault = annotatedElement.getAnnotation(Default.class);
            if (aDefault != null) {
                if (supportDefault) {
                    // Warn unusual usage. e.g. @Param @Default("a") Optional<String> param
                    if (isOptional) {
                        warnRedundantUse("@Default", "Optional");
                    } else if (isNullable) {
                        warnRedundantUse("@Default", nullableRepresentation);
                    }

                    shouldExist = false;
                    defaultValue = getSpecifiedValue(aDefault.value());
                } else {
                    // Warn if @Default exists in an unsupported place.
                    warnRedundantUse("@Default", null);

                    shouldExist = !isOptional;
                    // Set the default value to null just like it was not specified.
                    defaultValue = null;
                }
            } else {
                // Set the default value to null if it was not specified.
                defaultValue = null;

                if (isOptional) {
                    shouldExist = false;
                } else {
                    // Allow `null` if annotated with `@Nullable`.
                    shouldExist = !isNullable;
                }
            }

            if (pathVariable && !shouldExist) {
                if (isOptional) {
                    warnRedundantUse("a path variable", "Optional");
                } else {
                    warnRedundantUse("a path variable", nullableRepresentation);
                }
            }

            final Class<?> containerType = getContainerType(unwrappedParameterizedType);
            final Class<?> rawType;
            final Class<?> mayRawType = toRawType(unwrappedParameterizedType);
            if (mayRawType.isPrimitive()) {
                rawType = Primitives.wrap(mayRawType);
            } else {
                rawType = mayRawType;
            }
            final Class<?> elementType;
            final ParameterizedType parameterizedElementType;

            if (containerType != null) {
                elementType = getElementType(unwrappedParameterizedType, isOptional);
                parameterizedElementType = getParameterizedElementType(unwrappedParameterizedType);
            } else {
                //
                // Here, 'type' should be one of the following types:
                // - RequestContext (or ServiceRequestContext)
                // - Request (or HttpRequest)
                // - AggregatedHttpRequest
                // - QueryParams (or HttpParameters)
                // - User classes which can be converted by request converter
                //
                if (unwrappedParameterizedType instanceof Class) {
                    elementType = (Class<?>) unwrappedParameterizedType;
                    parameterizedElementType = null;
                } else if (unwrappedParameterizedType instanceof ParameterizedType) {
                    parameterizedElementType = (ParameterizedType) unwrappedParameterizedType;
                    elementType = (Class<?>) parameterizedElementType.getRawType();
                } else {
                    throw new IllegalArgumentException("Unsupported parameter type: " +
                                                       unwrappedParameterizedType.getTypeName());
                }
            }

            return new AnnotatedValueResolver(annotationType, httpElementName, pathVariable, shouldExist,
                                              isOptional, containerType, elementType, rawType,
                                              parameterizedElementType, defaultValue, description, resolver,
                                              beanFactoryId, aggregation);
        }
Sets an {@link AggregationStrategy} for the element.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedValueResolver.java