<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generation(self):
 """Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing """

        with self._lock:
            if self.state is not MemberState.STABLE:
                return None
            return self._generation