# Class HealthChangeBatch

java.lang.Object
com.codename1.health.HealthChangeBatch

public final class HealthChangeBatch extends Object
A set of changes since the last time a subscription was drained. Delivered to `HealthChangeListener` in the foreground and to `HealthBackgroundListener` after a background relaunch.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HealthChangeBatch(String subscriptionId, List<HealthDataType> types, List<HealthSample> added, List<String> deletedSampleIds, boolean resyncRequired, HealthAnchor anchor, long deadlineMillis, boolean more)`
  Creates a batch.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<HealthSample>`
  `getAdded()`
  Samples added or updated since the last drain.
  `HealthAnchor`
  `getAnchor()`
  The cursor after this batch.
  `long`
  `getDeadlineMillis()`
  Roughly how much wall-clock time the listener has before the OS may suspend the process, in milliseconds.
  `List<String>`
  `getDeletedSampleIds()`
  Identifiers of samples removed since the last drain.
  `String`
  `getSubscriptionId()`
  The subscription this batch belongs to.
  `List<HealthDataType>`
  `getTypes()`
  The types covered by this batch.
  `boolean`
  `hasMore()`
  `true` when more changes were available than `SubscriptionRequest.getMaxSamplesPerBatch()` allowed.
  `boolean`
  `isEmpty()`
  `true` when nothing changed and no resync is needed.
  `boolean`
  `isResyncRequired()`
  `true` when the platform cursor was lost and incremental delivery cannot continue -- a Health Connect change token older than 30 days, or an iOS anchor rejected after a restore from backup.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### HealthChangeBatch

    public HealthChangeBatch(String subscriptionId, List<HealthDataType> types, List<HealthSample> added, List<String> deletedSampleIds, boolean resyncRequired, HealthAnchor anchor, long deadlineMillis, boolean more)
    Creates a batch. Called by `HealthStore`; the lists are copied defensively.

- ## Method Details

  - ### getSubscriptionId

    public String getSubscriptionId()
    The subscription this batch belongs to.

  - ### getTypes

    public List<HealthDataType> getTypes()
    The types covered by this batch.

  - ### getAdded

    public List<HealthSample> getAdded()
    Samples added or updated since the last drain. Empty when the subscription set `SubscriptionRequest.setDeliverSamples(boolean)` to false, and empty when `isResyncRequired()`.

  - ### getDeletedSampleIds

    public List<String> getDeletedSampleIds()
    Identifiers of samples removed since the last drain.

  - ### isResyncRequired

    public boolean isResyncRequired()

    `true` when the platform cursor was lost and incremental delivery cannot continue -- a Health Connect change token older than 30 days, or an iOS anchor rejected after a restore from backup.

    `getAdded()` is empty in that case. The app must do a full time-range read to catch up; nothing else will deliver the missed data.

  - ### getAnchor

    public HealthAnchor getAnchor()
    The cursor after this batch. Persisted by `HealthStore` automatically; exposed for apps that checkpoint against their own server -- see `HealthAnchor`.

  - ### getDeadlineMillis

    public long getDeadlineMillis()

    Roughly how much wall-clock time the listener has before the OS may suspend the process, in milliseconds. About 5000 on an iOS background relaunch; `Long.MAX_VALUE` in the foreground.

    Do cheap bookkeeping inside a background delivery -- accumulate a counter, stash an identifier -- and leave network calls for the next foreground.

  - ### hasMore

    public boolean hasMore()
    `true` when more changes were available than `SubscriptionRequest.getMaxSamplesPerBatch()` allowed. The remainder arrives in the next delivery, or immediately on `HealthStore.drainChanges()`.

  - ### isEmpty

    public boolean isEmpty()
    `true` when nothing changed and no resync is needed.

  - ### toString

    public String toString()
    Description copied from class: `Object`
    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
    Overrides:
      `toString` in class `Object`