private void validateExclusiveMembers(
            Shape shape,
            Set<ShapeId> exclusiveMemberTraits,
            List<ValidationEvent> events
    ) {
        for (ShapeId traitId : exclusiveMemberTraits) {
            List<String> matches = new ArrayList<>();
            for (MemberShape member : shape.members()) {
                if (member.findTrait(traitId).isPresent()) {
                    matches.add(member.getMemberName());
                }
            }

            if (matches.size() > 1) {
                events.add(error(shape,
                        String.format(
                                "The `%s` trait can be applied to only a single member of a shape, but it was found on "
                                        + "the following members: %s",
                                Trait.getIdiomaticTraitName(traitId),
                                ValidationUtils.tickedList(matches))));
            }
        }
    }
Validates traits that can only be applied to a single structure member.
smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ExclusiveStructureMemberTraitValidator.java