protected static Optional headOption()

in src/main/java/com/spotify/bigtable/read/AbstractBigtableRead.java [125:134]


  protected static <A> Optional<A> headOption(final List<A> list) {
    if (list.size() > 1) {
      final String simpleName = list.get(0).getClass().getSimpleName();
      final String message = String.format(
          "Multiple entities of type %s matched when only 1 expected", simpleName
      );
      throw new RuntimeException(message);
    }
    return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
  }