SPARK-3969 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`.