Int2ObjectMap<String> (final int count) { final Int2ObjectOpenHashMap<String> fileIdToName = new Int2ObjectOpenHashMap<>(count); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final int maxNameSize = 50; final List<String> names = IntStream.range(0, count / 2)// E.V. 2 files per each name .mapToObj( i -> randomAlphanumericString(rnd, rnd.nextInt(1, maxNameSize)) ).toList(); for (int i = 0; i < count; i++) { int fileId; do { fileId = rnd.nextInt(Integer.MAX_VALUE); } while (fileIdToName.containsKey(fileId)); final String name = names.get(rnd.nextInt(names.size())); fileIdToName.put(fileId, name); } return fileIdToName; }