Sets and gets the value.

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

def set_and_get(self, new_value):
        """
        Sets and gets the value.

        :param new_value: (object), the new value.
        :return: (object), the new value.
        """
        return self._encode_invoke(atomic_reference_set_and_get_codec,
                                   new_value=self._to_data(new_value))