public final <T extends Trait> T expectTrait(Class<T> traitClass) {
        return getTrait(traitClass).orElseThrow(() -> new ExpectationNotMetException(String.format(
                "Expected shape `%s` to have a trait `%s`",
                getId(),
                traitClass.getCanonicalName()), this));
    }
Gets specific {@link Trait} by class from the shape or throws if not found.

@param traitClass Trait class to retrieve.
@param <T> The instance of the trait to retrieve.
@return Returns the matching trait.
@throws ExpectationNotMetException if the trait cannot be found.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/Shape.java