@SuppressWarnings("unchecked")
    public T writeOptional(Object content) {
        if (content == null) {
            return (T) this;
        } else if (content instanceof Optional) {
            return writeOptional(((Optional<?>) content).orElse(null));
        } else {
            String value = content.toString();
            return !value.isEmpty() ? write(value) : (T) this;
        }
    }
Optionally writes text to the AbstractCodeWriter and appends a newline
if a value is present.

<p>If the provided {@code content} value is {@code null}, nothing is
written. If the provided {@code content} value is an empty
{@code Optional}, nothing is written. If the result of calling
{@code toString} on {@code content} results in an empty string,
nothing is written. Finally, if the value is a non-empty string,
the content is written to the {@code AbstractCodeWriter} at the current
level of indentation, and a newline is appended.

@param content Content to write if present.
@return Returns self.
smithy-utils/src/main/java/software/amazon/smithy/utils/AbstractCodeWriter.java