This repository has been archived by the owner on May 7, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added composite job if range events are scheduled at same time instant
Signed-off-by: Amit Kumar Mondal <admin@amitinside.com>
- Loading branch information
Showing
2 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...ng.astro/src/main/java/org/eclipse/smarthome/binding/astro/internal/job/CompositeJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2017 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.binding.astro.internal.job; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* {@link CompositeJob} comprises multiple {@link Job}s to be executed in order | ||
* | ||
* @author Markus Rathgeb - Initial contribution | ||
* @author Amit Kumar Mondal - Minor modifications | ||
*/ | ||
public final class CompositeJob extends AbstractJob { | ||
|
||
private final String thingUID; | ||
private final List<Job> jobs; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param jobs the jobs to execute | ||
* @throws IllegalArgumentException if {@code jobs} is {@code null} or empty | ||
*/ | ||
public CompositeJob(List<Job> jobs) { | ||
checkArgument(jobs != null, "Jobs must not be null"); | ||
checkArgument(!jobs.isEmpty(), "Jobs must not be empty"); | ||
|
||
this.jobs = jobs; | ||
this.thingUID = jobs.get(0).getThingUID(); | ||
} | ||
|
||
@Override | ||
public String getThingUID() { | ||
return thingUID; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
jobs.stream().forEach(Job::run); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters