@NonNull
  Bundle encode(@NonNull JobParameters jobParameters, @NonNull Bundle data) {
    if (data == null) {
      throw new IllegalArgumentException("Unexpected null Bundle provided");
    }

    Bundle userExtras = jobParameters.getExtras();
    if (userExtras != null) {
      data.putAll(userExtras);
    }

    data.putInt(prefix + BundleProtocol.PACKED_PARAM_LIFETIME, jobParameters.getLifetime());
    data.putBoolean(prefix + BundleProtocol.PACKED_PARAM_RECURRING, jobParameters.isRecurring());
    data.putBoolean(
        prefix + BundleProtocol.PACKED_PARAM_REPLACE_CURRENT, jobParameters.shouldReplaceCurrent());
    data.putString(prefix + BundleProtocol.PACKED_PARAM_TAG, jobParameters.getTag());
    data.putString(prefix + BundleProtocol.PACKED_PARAM_SERVICE, jobParameters.getService());
    data.putInt(
        prefix + BundleProtocol.PACKED_PARAM_CONSTRAINTS, compact(jobParameters.getConstraints()));

    encodeTrigger(jobParameters.getTrigger(), data);
    encodeRetryStrategy(jobParameters.getRetryStrategy(), data);

    return data;
  }
JobCoder is a tool to encode and decode JobSpecs from Bundles.
jobdispatcher/src/main/java/com/firebase/jobdispatcher/JobCoder.java