public final class TraitChangeBatch
- Object
- TraitChangeBatch
A coalesced set of trait changes, delivered to a HomeChangeListener on
the EDT.
One entry per trait, not one per change
Within the subscription’s window – see
SubscriptionRequest.setMinIntervalMillis(int) – changes are collapsed
per accessory, service and trait, keeping only the newest value. Dragging a
dimmer produces one reading showing where it ended up, not forty showing
the journey.
That means a batch is a state update, not an event log: you cannot count changes from it and you cannot see intermediate values. If you need every step, set the window to zero and accept the cost.
Constructors
public TraitChangeBatch(String subscriptionId, List<TraitReading> readings, boolean initialDelivery, boolean resyncRequired) | Creates a batch. |
Methods
public String getSubscriptionId() | Which subscription produced this batch. |
public List<TraitReading> getReadings() | The changed values, one per trait that moved. |
public boolean isInitialDelivery() | Whether this is the up-front delivery of current values rather than a report of something that just changed. |
public boolean isResyncRequired() | Whether changes were missed and the values you hold cannot be trusted. |
public boolean isEmpty() | Whether this batch carries no readings. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Constructor details
TraitChangeBatch
public TraitChangeBatch(String subscriptionId, List<TraitReading> readings, boolean initialDelivery, boolean resyncRequired)Parameters
subscriptionIdString- which subscription produced this
readingsList<TraitReading>- the coalesced changes;
nullbecomes empty initialDeliveryboolean- whether this is the up-front delivery of current
values requested by
SubscriptionRequest.setDeliverInitialValues(boolean) resyncRequiredboolean- whether changes were missed
Method details
getSubscriptionId
public String getSubscriptionId()Which subscription produced this batch.
Matches TraitSubscription.getId(). Worth checking when one listener
serves several subscriptions.
Returns
nullgetReadings
public List<TraitReading> getReadings()The changed values, one per trait that moved.
A reading here can have no value or carry an error, exactly as one from
a read can – an accessory going unreachable is a change worth
delivering. See TraitReading.
Returns
isInitialDelivery
public boolean isInitialDelivery()Returns
true for the initial deliveryisResyncRequired
public boolean isResyncRequired()Whether changes were missed and the values you hold cannot be trusted.
The platform dropped its notification stream – the app was backgrounded long enough, the connection to a hub was rebuilt, the accessory rejoined. The readings in this batch are still good; everything else you were tracking through this subscription is stale.
Re-read the traits you care about with
SmartHome.read(TraitReadRequest). Ignoring this leaves a UI showing
values from before the gap, indefinitely, with nothing to indicate it.
Returns
true when a full re-read is neededisEmpty
public boolean isEmpty()Whether this batch carries no readings.
An empty batch is delivered only when isResyncRequired() is true
– a resync is worth telling you about even with nothing to show.
Returns
true when there are no readingstoString
public String toString()