# CarValue

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/hardware/common/CarValue.java+class:androidx.car.app.hardware.common.CarValue) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 3)
class CarValue<T>
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` |

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#STATUS_SUCCESS() = 1` `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` was obtained successfully. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#STATUS_UNAVAILABLE() = 3` `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` attempted for unavailable property, sensor, or action. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#STATUS_UNIMPLEMENTED() = 2` `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` attempted for unimplemented property, sensor, or action. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#STATUS_UNKNOWN() = 0` `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` has unknown status. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#CarValue(T,long,int)(value: T?, timestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, status: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Constructs a new instance of a `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#CarValue(T,long,int,java.util.List<androidx.car.app.hardware.common.CarZone>)( value: T?, timestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, status: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, zones: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarZone!> )` Constructs a new instance of a `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#equals(java.lang.Object)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarZone!>` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getCarZones()()` Returns a list of car zones associated with this `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getStatus()()` Returns the status of this particular result such as success, unavailable, or unimplemented. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getTimestampMillis()()` Returns the time in milliseconds at which the event happened. |
| `T?` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getValue()()` Returns a the data value or `null` if the status is not successful. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#toString()()` |

## Constants

### STATUS_SUCCESS

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
const val STATUS_SUCCESS = 1: Int
```

`https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` was obtained successfully.

### STATUS_UNAVAILABLE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
const val STATUS_UNAVAILABLE = 3: Int
```

`https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/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

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
const val STATUS_UNIMPLEMENTED = 2: Int
```

`https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/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

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
const val STATUS_UNKNOWN = 0: Int
```

`https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue` has unknown status.

## Public constructors

### CarValue

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
CarValue(value: T?, timestampMillis: Long, status: Int)
```

Constructs a new instance of a `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`. Uses `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarZone#CAR_ZONE_GLOBAL()` as the zone for this instance.

| Parameters |
|---|---|
| `value: T?` | data to be returned with the result |
| `timestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the time in milliseconds when the value was generated (see `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getTimestampMillis()`) |
| `status: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the status code associated with this value |

### CarValue

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
CarValue(
    value: T?,
    timestampMillis: Long,
    status: Int,
    zones: (Mutable)List<CarZone!>
)
```

Constructs a new instance of a `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`.

| Parameters |
|---|---|
| `value: T?` | data to be returned with the result |
| `timestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the time in milliseconds when the value was generated (see `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getTimestampMillis()`) |
| `status: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the status code associated with this value |
| `zones: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarZone!>` | the car zones associated with this value |

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```

### getCarZones

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
fun getCarZones(): (Mutable)List<CarZone!>
```

Returns a list of car zones associated with this `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue`.

For a global vehicle function, the list will only contain `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarZone#CAR_ZONE_ROW_ALL()`. Returns an empty list when `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getStatus()` is `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#STATUS_UNIMPLEMENTED()`.

### getStatus

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
fun getStatus(): Int
```

Returns the status of this particular result such as success, unavailable, or unimplemented.

### getTimestampMillis

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
fun getTimestampMillis(): Long
```

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().

### getValue

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
fun getValue(): T?
```

Returns a the data value or `null` if the status is not successful.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue#getStatus()` |   |

### hashCode

```
fun hashCode(): Int
```

### toString

```
fun toString(): String
```