code: public boolean cas(T expected, T newValue) {
          try {
              lock.writeLock().lock();
  
              if (Objects.equals(value, expected)) {
                  this.value = newValue;
                  return true;
              } else
                  return false;
          } finally {
              lock.writeLock().unlock();
          }
      }
docs: This method implements compare-and-swap
  
  @param expected
  @param newValue
  @return true if value was swapped, false otherwise