Gets the old value and sets the new value.

        :param new_value: (object), the new value.
        :return: (object), the old value.

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))