static <T> T requiredState(String method, T value) {
        if (value == null) {
            StringBuilder message = new StringBuilder(method).append(" was not set on the builder");

            // Include the builder class that could not be built.
            StackTraceElement[] elements = Thread.currentThread().getStackTrace();
            if (elements.length >= 2) {
                String builder = elements[2].getClassName();
                message.append(" (builder class is probably ").append(builder).append(')');
            }

            throw new IllegalStateException(message.toString());
        }
        return value;
    }
Convenience method for ensuring that a value was set on a builder,
and if not, throws an IllegalStateException with a useful message.

@param method Method that needs to be called to set this value.
@param value Value to check.
@param <T> Type of value being checked.
@return Returns the value.
smithy-utils/src/main/java/software/amazon/smithy/utils/SmithyBuilder.java