private static Set<MediaType> listToSet(List<MediaType> types, Class<?> annotationClass) {
        final Set<MediaType> set = new LinkedHashSet<>();
        for (final MediaType type : types) {
            if (!set.add(type)) {
                throw new IllegalArgumentException(
                        "Duplicated media type for @" + annotationClass.getSimpleName() + ": " + type);
            }
        }
        return ImmutableSet.copyOf(set);
    }
Converts the list of {@link MediaType}s to a set. It raises an {@link IllegalArgumentException} if the
list has duplicate elements.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedServiceFactory.java