2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.astro.internal.job;
15 import java.util.List;
16 import java.util.stream.Collectors;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * {@link CompositeJob} comprises multiple {@link Job}s to be executed in order
23 * @author Markus Rathgeb - Initial contribution
24 * @author Amit Kumar Mondal - Minor modifications
27 public final class CompositeJob extends AbstractJob {
29 private final List<Job> jobs;
34 * @param thingUID thing UID
35 * @param jobs the jobs to execute
36 * @throws IllegalArgumentException
37 * if {@code jobs} is {@code null} or empty
39 public CompositeJob(String thingUID, List<Job> jobs) {
44 boolean notMatched = jobs.stream().anyMatch(j -> !j.getThingUID().equals(thingUID));
45 checkArgument(!notMatched, "The jobs must associate the same thing UID");
53 } catch (RuntimeException ex) {
54 LOGGER.warn("Job execution failed.", ex);
60 public String toString() {
61 return jobs.stream().map(j -> j.toString()).collect(Collectors.joining(" + "));