CarValue
@CarProtocol
@RequiresCarApi(value = 3)
public final class CarValue<T>
A data value object returned from car hardware with associated metadata including status, timestamp, and the actual value.
| Parameters | |
|---|---|
<T> |
data type which is returned by the |
Summary
Constants |
|
|---|---|
static final int |
STATUS_SUCCESS = 1
|
static final int |
|
static final int |
|
static final int |
STATUS_UNKNOWN = 0
|
Public constructors |
|---|
|
Constructs a new instance of a |
|
Constructs a new instance of a |
Public methods |
|
|---|---|
boolean |
|
@NonNull List<CarZone> |
Returns a list of car zones associated with this |
int |
Returns the status of this particular result such as success, unavailable, or unimplemented. |
long |
Returns the time in milliseconds at which the event happened. |
@Nullable T |
getValue()Returns a the data value or |
int |
hashCode() |
@NonNull String |
toString() |
Constants
STATUS_SUCCESS
public static final int STATUS_SUCCESS = 1
CarValue was obtained successfully.
STATUS_UNAVAILABLE
public static final int STATUS_UNAVAILABLE = 3
CarValue attempted for unavailable property, sensor, or action.
For example, the car hardware might not be able to return a value such as climate at the current time because the engine is off and will set the status to this value.
STATUS_UNIMPLEMENTED
public static final int STATUS_UNIMPLEMENTED = 2
CarValue attempted for unimplemented property, sensor, or action.
For example, the car hardware might not be able to return a value such as speed or energy level and will set the status to this value.
STATUS_UNKNOWN
public static final int STATUS_UNKNOWN = 0
CarValue has unknown status.
Public constructors
CarValue
public CarValue(@Nullable T value, long timestampMillis, int status)
Constructs a new instance of a CarValue. Uses CAR_ZONE_GLOBAL as the zone for this instance.
| Parameters | |
|---|---|
@Nullable T value |
data to be returned with the result |
long timestampMillis |
the time in milliseconds when the value was generated (see |
int status |
the status code associated with this value |
CarValue
public CarValue(
@Nullable T value,
long timestampMillis,
int status,
@NonNull List<CarZone> zones
)
Constructs a new instance of a CarValue.
| Parameters | |
|---|---|
@Nullable T value |
data to be returned with the result |
long timestampMillis |
the time in milliseconds when the value was generated (see |
int status |
the status code associated with this value |
@NonNull List<CarZone> zones |
the car zones associated with this value |
Public methods
getCarZones
public @NonNull List<CarZone> getCarZones()
Returns a list of car zones associated with this CarValue.
For a global vehicle function, the list will only contain GLOBAL_ZONE. Returns an empty list when getStatus is STATUS_UNIMPLEMENTED.
getStatus
public int getStatus()
Returns the status of this particular result such as success, unavailable, or unimplemented.
getTimestampMillis
public long getTimestampMillis()
Returns the time in milliseconds at which the event happened.
For a given property, sensor, or action, each new value's timestamp should be monotonically increasing using the same time base as SystemClock.elapsedRealtime().