class PcapHandle implements Closeable {

  public void setDirection(PcapDirection direction) throws PcapNativeException, NotOpenException {
    if (direction == null) {
      throw new NullPointerException("direction must not be null.");
    }
    if (!open) {
      throw new NotOpenException();
    }

    if (!handleLock.readLock().tryLock()) {
      throw new NotOpenException();
    }
    try {
      if (!open) {
        throw new NotOpenException();
      }

      int rc = NativeMappings.pcap_setdirection(handle, direction.getValue());
      if (rc < 0) {
        throw new PcapNativeException("Failed to set direction: " + getError(), rc);
      }
    } finally {
      handleLock.readLock().unlock();
    }
  }

    PcapHandle(Pointer handle, TimestampPrecision timestampPrecision);
  private  PcapHandle(Builder builder);

}