@Override
    public T copy() {
        if (owned != null) {
            // The currently owned value will be the copied result. The reference will keep a "borrowed"
            // pointer to this value. Use peek() to get or create an immutably wrapped owned value.
            T result = peek();
            setOwned(null);
            borrowed = result;
            return result;
        } else if (borrowed != null) {
            // Copy the borrowed value and make it immutable.
            return applyImmutableWrapper(applyCopyCtor(borrowed));
        } else if (emptyCtorOptimization != null) {
            // The value is empty and was never created, so call the empty ctor supplier if available.
            return applyEmptyCtorOptimization();
        } else {
            // Cache the value so subsequent calls to peek reuse the computed value.
            borrowed = applyImmutableWrapper(applyCtor());
            return borrowed;
        }
    }
Default implementation of {@link BuilderRef}.

<p>This class is not threadsafe; it should only be used to build up
other objects using {@link #copy()}.

@param <T> The type of value being built, borrowed, and copied.
smithy-utils/src/main/java/software/amazon/smithy/utils/DefaultBuilderRef.java