In fact, the state is complex, it may be a combined state, can not be compared using ==.

Your first suggestion is right, hasState is better.