default <T> T getByType(Class<T> type) {
        if (type.isAssignableFrom(BeforeEachSpec.class)) {
            if (Objects.isNull(getBeforeEachSpec())) {
                return type.cast(BeforeEachSpec.DEFAULT);
            }
            return type.cast(getBeforeEachSpec());
        }
        if (type.isAssignableFrom(AfterEachSpec.class)) {
            if (Objects.isNull(getAfterEachSpec())) {
                return type.cast(AfterEachSpec.DEFAULT);
            }
            return type.cast(getAfterEachSpec());
        }
        if (type.isAssignableFrom(CaseSpec.class)) {
            return type.cast(getCaseSpec());
        }
        return null;
    }
Verify which type the class belongs to.

@param type type
@param <T> &lt;T&gt;
@return T
shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpec.java