class UniquePortSupplier {

  public synchronized int getAvailablePort() {
    int result = IntStream.generate(supplier)
        .filter(port -> !usedPorts.contains(port))
        .findFirst()
        .getAsInt();

    usedPorts.add(result);
    return result;
  }

  public  UniquePortSupplier();
  public  UniquePortSupplier(IntSupplier supplier);

}