/** * Returns a sequential {@code StreamEx} containing the results of applying * the given function to the corresponding pairs of values in given two * arrays. * * @param <U> the type of the first array elements * @param <V> the type of the second array elements * @param <T> the type of the resulting stream elements * @param first the first array * @param second the second array * @param mapper a non-interfering, stateless function to apply to each pair * of the corresponding array elements. * @return a new {@code StreamEx} * @throws IllegalArgumentException if length of the arrays differs. * @see EntryStream#zip(Object[], Object[]) * @since 0.2.1 */ public static <U, V, T> StreamEx<T> zip(U[] first, V[] second, BiFunction<? super U, ? super V, ? extends T> mapper) { return zip(Arrays.asList(first), Arrays.asList(second), mapper); }
@SuppressWarnings("unchecked") private List<Job> activateJobs(String jobType, String worker, Duration timeout, int amount) { final Map<String, Object> response = apiRule .createCmdRequest() .type(ValueType.JOB_BATCH, JobBatchIntent.ACTIVATE) .command() .put("type", jobType) .put("worker", worker) .put("timeout", timeout.toMillis()) .put("amount", amount) .put("jobs", Collections.emptyList()) .done() .sendAndAwait() .getValue(); return StreamEx.zip( ((List<Long>) response.get("jobKeys")), ((List<Map<String, Object>>) response.get("jobs")), Job::new) .collect(Collectors.toList()); }
@SuppressWarnings("unchecked") private List<Job> activateJobs(String jobType, String worker, Duration timeout, int amount) { final Map<String, Object> response = apiRule .createCmdRequest() .type(ValueType.JOB_BATCH, JobBatchIntent.ACTIVATE) .command() .put("type", jobType) .put("worker", worker) .put("timeout", timeout.toMillis()) .put("amount", amount) .put("jobs", Collections.emptyList()) .done() .sendAndAwait() .getValue(); return StreamEx.zip( ((List<Long>) response.get("jobKeys")), ((List<Map<String, Object>>) response.get("jobs")), Job::new) .collect(Collectors.toList()); }