SchedulerConstraint.java

  1. package com.birbit.android.jobqueue.scheduling;

  2. import android.support.annotation.Nullable;

  3. import com.birbit.android.jobqueue.network.NetworkUtil;

  4. /**
  5.  * The constraints that are passed into Scheduler from JobManager
  6.  */
  7. public class SchedulerConstraint {
  8.     private String uuid;
  9.     private long delayInMs;
  10.     private int networkStatus;
  11.     private Long overrideDeadlineInMs;
  12.     // arbitrary data that can be used by the scheduler
  13.     private Object data;

  14.     public SchedulerConstraint(String uuid) {
  15.         this.uuid = uuid;
  16.     }

  17.     /**
  18.      * The unique id assigned by the job manager. This is different from the ID that is assigned
  19.      * by the third party scheduler.
  20.      * @return The unique id assigned by the job manager
  21.      */
  22.     public String getUuid() {
  23.         return uuid;
  24.     }

  25.     public void setUuid(String uuid) {
  26.         this.uuid = uuid;
  27.     }

  28.     /**
  29.      * The delay for the job
  30.      * @return The delay before running the job
  31.      */
  32.     public long getDelayInMs() {
  33.         return delayInMs;
  34.     }

  35.     public void setDelayInMs(long delayInMs) {
  36.         this.delayInMs = delayInMs;
  37.     }

  38.     /**
  39.      *
  40.      * @return The network status required to run the job.
  41.      */
  42.     @NetworkUtil.NetworkStatus
  43.     public int getNetworkStatus() {
  44.         return networkStatus;
  45.     }

  46.     public void setNetworkStatus(int networkStatus) {
  47.         this.networkStatus = networkStatus;
  48.     }

  49.     public Object getData() {
  50.         return data;
  51.     }

  52.     public void setData(Object data) {
  53.         this.data = data;
  54.     }

  55.     /**
  56.      * The deadline in ms after which the job should be run even if the constraints are not match.
  57.      * <p>
  58.      * If there is no deadline, this will be null.
  59.      *
  60.      * @return The time in ms until the constraints timeout
  61.      */
  62.     @Nullable
  63.     public Long getOverrideDeadlineInMs() {
  64.         return overrideDeadlineInMs;
  65.     }

  66.     public void setOverrideDeadlineInMs(Long overrideDeadlineInMs) {
  67.         this.overrideDeadlineInMs = overrideDeadlineInMs;
  68.     }

  69.     @Override
  70.     public String toString() {
  71.         return "SchedulerConstraint{" +
  72.                 "uuid='" + uuid + '\'' +
  73.                 ", delayInMs=" + delayInMs +
  74.                 ", networkStatus=" + networkStatus +
  75.                 ", overrideDeadlineInMs=" + overrideDeadlineInMs +
  76.                 ", data=" + data +
  77.                 '}';
  78.     }
  79. }