private static BiFunction<AnnotatedValueResolver, ResolverContext, Object>
    attributeResolver(Iterable<AttributeKey<?>> attrKeys) {
        return (resolver, ctx) -> {
            Class<?> targetType = resolver.rawType();
            if (targetType.isPrimitive()) {
                targetType = Primitives.wrap(targetType);
            }

            for (AttributeKey<?> attrKey : attrKeys) {
                final Object value = ctx.context.attr(attrKey);
                if (value != null) {
                    if (!targetType.isInstance(value)) {
                        throw new IllegalStateException(
                                String.format("Cannot inject the attribute '%s' due to " +
                                              "mismatching type (expected: %s, actual: %s)",
                                              attrKey.name(),
                                              targetType.getName(),
                                              value.getClass().getName()));
                    }
                    return value;
                }
            }
            return resolver.defaultOrException();
        };
    }
Returns an attribute resolver which retrieves a value specified by {@code attrKeys}
from the {@link RequestContext}.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedValueResolver.java