private void serializeTraits(Map<ShapeId, Trait> traits, TraitFeature... traitFeatures) {
            boolean noSpecialDocsSyntax = TraitFeature.NO_SPECIAL_DOCS_SYNTAX.hasFeature(traitFeatures);
            boolean isMember = TraitFeature.MEMBER.hasFeature(traitFeatures);

            // The documentation trait always needs to be serialized first since it uses special syntax.
            if (!noSpecialDocsSyntax && traits.containsKey(DocumentationTrait.ID)) {
                Trait documentation = traits.get(DocumentationTrait.ID);
                if (traitFilter.test(documentation)) {
                    serializeDocumentation(documentation.toNode().expectStringNode().getValue());
                }
            }

            Comparator<Trait> traitComparator = componentOrder.toShapeIdComparator();

            traits.values()
                    .stream()
                    .filter(trait -> noSpecialDocsSyntax || !trait.toShapeId().equals(DocumentationTrait.ID))
                    // The default and enumValue traits are serialized using the assignment syntactic sugar.
                    .filter(trait -> {
                        if (trait instanceof EnumValueTrait) {
                            return false;
                        } else {
                            // Default traits are serialized normally for non-members, but omitted for members.
                            return !isMember || !(trait instanceof DefaultTrait);
                        }
                    })
                    .filter(traitFilter)
                    .sorted(traitComparator)
                    .forEach(this::serializeTrait);
        }
Serializes shapes in the IDL format.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/SmithyIdlModelSerializer.java