code: public void setCapacity(int capacity) {
          if (capacity < 0) {
              throw new IllegalArgumentException();
          }
          this.capacity = Math.min(capacity, MAXIMUM_CAPACITY);
  
          evictionLock.lock();
          try {
              drainBuffers(AMORTIZED_DRAIN_THRESHOLD);
              evict();
          } finally {
              evictionLock.unlock();
          }
          notifyListener();
      }
docs: Sets the maximum weighted capacity of the map and eagerly evicts entries
  until it shrinks to the appropriate size.
  
  @param capacity the maximum weighted capacity of the map
  @throws IllegalArgumentException if the capacity is negative