<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_and_set(self, new_value):
 """ Gets the old value and sets the new value. :param new_value: (object), the new value. :return: (object), the old value. """

        return self._encode_invoke(atomic_reference_get_and_set_codec,
                                   new_value=self._to_data(new_value))