public final class TraitWriteResult
- Object
- TraitWriteResult
What happened to one TraitWrite.
A batch write partly succeeding is normal, not exceptional
“Turn off every light” against a home with a dead bulb in it is a request
that mostly worked. Failing the whole operation would be wrong – the other
eight lights are off, and telling the caller nothing happened would have
them retry and flicker the house. So SmartHome.write(java.util.List)
resolves successfully with one of these per write, and the caller decides
what a partial result means for them.
The operation’s own AsyncResource fails only when the request never
reached the platform at all – unauthorized, not configured, malformed.
Methods
public static TraitWriteResult applied(TraitWrite write) | A write the accessory accepted. |
public static TraitWriteResult failed(TraitWrite write, HomeError error, String message) | A write the accessory did not accept. |
public TraitWrite getWrite() | The write this describes. |
public boolean isApplied() | Whether the accessory accepted the write. |
public HomeError getError() | Why the write failed. |
public String getErrorMessage() | The platform’s own text for a failure. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Method details
applied
public static TraitWriteResult applied(TraitWrite write)Parameters
writeTraitWrite- the write that succeeded
Returns
Throws
IllegalArgumentException- when
writeisnull
failed
public static TraitWriteResult failed(TraitWrite write, HomeError error, String message)Parameters
writeTraitWrite- the write that failed
errorHomeError- why;
nullbecomesHomeError.UNKNOWN messageString- the platform’s own text, or
null
Returns
Throws
IllegalArgumentException- when
writeisnull
getWrite
public TraitWrite getWrite()Returns
nullisApplied
public boolean isApplied()Whether the accessory accepted the write.
Note what this does not claim: that the accessory has finished
doing it. A covering that accepted “go to 40 percent” will be moving
for some seconds afterwards, and a fan ramps. Watch
Trait.COVERING_MOTION or subscribe to the trait if you need to know
when it settles.
Returns
true when the write was acceptedgetError
public HomeError getError()Returns
null when it succeededgetErrorMessage
public String getErrorMessage()Returns
nulltoString
public String toString()