@Override
    protected void check(Shape shape, UniqueItemsTrait trait, ArrayNode value, Context context, Emitter emitter) {
        Set<Node> uniqueNodes = new HashSet<>(value.getElements());
        if (uniqueNodes.size() != value.size()) {
            List<Node> duplicateNodes = new ArrayList<>(value.getElements());
            for (Node uniqueNode : uniqueNodes) {
                // Collections remove the first encountered entry, so our unique
                // nodes through a set will leave behind any duplicates.
                duplicateNodes.remove(uniqueNode);
            }

            Set<String> duplicateValues = new LinkedHashSet<>();
            for (Node duplicateNode : duplicateNodes) {
                duplicateValues.add(duplicateNode.toString());
            }
            emitter.accept(value,
                    String.format(
                            "Value provided for `%s` must have unique items, but the following items had multiple entries: "
                                    + "[`%s`]",
                            shape.getId(),
                            String.join("`, `", duplicateValues)));
        }
    }
Validates that items in lists with the `@uniqueItems` trait are unique.
smithy-model/src/main/java/software/amazon/smithy/model/validation/node/UniqueItemsPlugin.java