Package org.eclipse.hono.util
Class TimeUntilDisconnectNotification
- java.lang.Object
-
- org.eclipse.hono.util.TimeUntilDisconnectNotification
-
public final class TimeUntilDisconnectNotification extends Object
Contains all information about a device that is indicating being ready to receive an upstream message.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Optional<TimeUntilDisconnectNotification>
fromMessage(org.apache.qpid.proton.message.Message msg)
Creates a notification from an AMQP message.Instant
getCreationTime()
Gets the point in time that the message has been created at.String
getDeviceId()
Gets the identifier of the device that sent the TTD.long
getMillisecondsUntilExpiry()
Get the time in milliseconds left from the current time until this notification expires.Instant
getReadyUntil()
Gets the point in time until which the device will remain connected.String
getTenantAndDeviceId()
Get a representation of the deviceId scoped to the tenant.String
getTenantId()
Gets the identifier of the tenant that the device belongs to.Integer
getTtd()
Gets the time period that the device indicated to remain connected.String
toString()
-
-
-
Method Detail
-
getTenantId
public String getTenantId()
Gets the identifier of the tenant that the device belongs to.- Returns:
- The identifier.
-
getDeviceId
public String getDeviceId()
Gets the identifier of the device that sent the TTD.- Returns:
- The identifier.
-
getTenantAndDeviceId
public String getTenantAndDeviceId()
Get a representation of the deviceId scoped to the tenant.- Returns:
- The combined representation, or
null
if the tenantId isnull
.
-
getTtd
public Integer getTtd()
Gets the time period that the device indicated to remain connected.- Returns:
- The time period in seconds.
-
getReadyUntil
public Instant getReadyUntil()
Gets the point in time until which the device will remain connected.- Returns:
- The point in time.
-
getCreationTime
public Instant getCreationTime()
Gets the point in time that the message has been created at.- Returns:
- The creation time.
-
fromMessage
public static Optional<TimeUntilDisconnectNotification> fromMessage(org.apache.qpid.proton.message.Message msg)
Creates a notification from an AMQP message.The notification will contain information extracted from the AMQP message as follows:
- ttd - the value of the
MessageHelper.APP_PROPERTY_DEVICE_TTD
application property - tenantId - the value of the
MessageHelper.APP_PROPERTY_TENANT_ID
application property - deviceId - the value of the
MessageHelper.APP_PROPERTY_DEVICE_ID
application property - creationTime - the value of the message's creation-time property
- readyUntil - the instant until the device will remain connected
- Parameters:
msg
- Message that is evaluated.- Returns:
- A notification if the message contains a
TTD value in its
MessageHelper.APP_PROPERTY_DEVICE_TTD
application property ornull
otherwise. - Throws:
NullPointerException
- If msg isnull
.
- ttd - the value of the
-
getMillisecondsUntilExpiry
public long getMillisecondsUntilExpiry()
Get the time in milliseconds left from the current time until this notification expires.- Returns:
- The number of milliseconds until this notification expires, or 0 if the notification is already expired.
-
-