Class 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TraitWriteResultapplied(TraitWrite write) A write the accessory accepted.static TraitWriteResultfailed(TraitWrite write, HomeError error, String message) A write the accessory did not accept.getError()Why the write failed.The platform's own text for a failure.getWrite()The write this describes.booleanWhether the accessory accepted the write.toString()Returns a string representation of the object.
-
Method Details
-
applied
A write the accessory accepted.
Parameters
write: the write that succeeded
Returns
the result
Throws
IllegalArgumentException: whenwriteisnull
-
failed
A write the accessory did not accept.
Parameters
-
write: the write that failed -
error: why;nullbecomesHomeError.UNKNOWN -
message: the platform's own text, ornull
Returns
the result
Throws
IllegalArgumentException: whenwriteisnull
-
-
getWrite
The write this describes.
Returns
the write, never
null -
isApplied
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_MOTIONor subscribe to the trait if you need to know when it settles.Returns
truewhen the write was accepted -
getError
Why the write failed.
Returns
the error, or
nullwhen it succeeded -
getErrorMessage
The platform's own text for a failure.
Returns
the message, or
null -
toString
Description copied from class:ObjectReturns 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())
-