# TypeConverter

Artifact: [androidx.core:core-animation](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/animation/TypeConverter.java+class:androidx.core.animation.TypeConverter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

*** ** * ** ***


```
public abstract class TypeConverter<T, V>
```

<br />

Known direct subclasses [BidirectionalTypeConverter](https://developer.android.com/reference/androidx/core/animation/BidirectionalTypeConverter)

|---|---|
| `https://developer.android.com/reference/androidx/core/animation/BidirectionalTypeConverter` | Abstract base class used convert type T to another type V and back again. |

*** ** * ** ***

Abstract base class used convert type T to another type V. This is necessary when the value types of in animation are different from the property type.

| Parameters |
|---|---|
| `<T>` | type T. It can be converted to type V |
| `<V>` | type V. It can be converted from type T |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/animation/PropertyValuesHolder#setConverter(androidx.core.animation.TypeConverter)` |   |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/animation/TypeConverter#TypeConverter(java.lang.Class<T>,java.lang.Class<V>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html<T> fromClass, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html<V> toClass)` Constructor for creating a type converter instance that converts type T to another type V. |

| ### Public methods |
|---|---|
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html V` | `https://developer.android.com/reference/androidx/core/animation/TypeConverter#convert(T)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html T value)` Converts a value from one type to another. |

## Public constructors

### TypeConverter

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public TypeConverter(@NonNull Class<T> fromClass, @NonNull Class<V> toClass)
```

Constructor for creating a type converter instance that converts type T to another type V.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html<T> fromClass` | class of the value type that feeds into the converter |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html<V> toClass` | class of the value type expected out of the converter |

## Public methods

### convert

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract @NonNull V convert(@NonNull T value)
```

Converts a value from one type to another.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html T value` | The Object to convert. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html V` | A value of type V, converted from `value`. |