public static Optional<EnumShape> fromStringShape(StringShape shape, boolean synthesizeNames) {
        if (shape.isEnumShape()) {
            return Optional.of((EnumShape) shape);
        }

        if (!shape.hasTrait(EnumTrait.ID)) {
            return Optional.empty();
        }
        StringShape stringWithoutEnumTrait = shape.toBuilder().removeTrait(EnumTrait.ID).build();
        Builder enumBuilder = EnumShape.builder();
        stringWithoutEnumTrait.updateBuilder(enumBuilder);
        try {
            return Optional.of(enumBuilder
                    .setMembersFromEnumTrait(shape.expectTrait(EnumTrait.class), synthesizeNames)
                    .build());
        } catch (IllegalStateException e) {
            LOGGER.info(String.format("Unable to convert `%s` to an enum: %s", shape.getId(), e));
            return Optional.empty();
        }
    }
Converts a base {@link StringShape} to an {@link EnumShape} if possible.

The result will be empty if the given shape doesn't have the {@link EnumTrait},
if the enum doesn't have names and name synthesization is disabled, or if a name
cannot be synthesized.

@param shape A base {@link StringShape} to convert.
@param synthesizeNames Whether names should be synthesized if possible.
@return Optionally returns an {@link EnumShape} equivalent of the given shape.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/EnumShape.java