[SPARK-3969][SQL] Optimizer should have a super class as an interface.

Some developers want to replace `Optimizer` to fit their projects but can't do so because currently `Optimizer` is an `object`.
Hi @srowen, thank you for your comment.
I'll rename the `object`.
And yes, this PR is a very little API change.