code: public static void keyPresent(final String key, final Map<String, ?> map) {
      if (!map.containsKey(key)) {
        throw new IllegalStateException(
            String.format("expected %s to be present", key));
      }
    }
docs: Throw IllegalStateException if key is not present in map.
  @param key the key to expect.
  @param map the map to search.
  @throws IllegalArgumentException if key is not in map.