# ProtoUtils

Artifact: [androidx.test.espresso:espresso-remote](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/remote/ProtoUtils.java+class:androidx.test.espresso.remote.ProtoUtils)

*** ** * ** ***

<br />

```
class ProtoUtils
```

<br />

*** ** * ** ***

Contains various utility methods to ease use of protos and increased readability in code.

## Summary

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/ProtoUtils#capitalizeFirstChar(java.lang.String)(aString: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Capitalizes the first char of a String. |
| `java-static T!` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-enum/index.html?> https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/ProtoUtils#checkedGetEnumForProto(int,java.lang.Class<T>)(protoEnumIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, enumClass: https://developer.android.com/reference/java/lang/Class.html<T!>!)` Maps an enum proto message type to a internal representation enum type T. |
| `java-static (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/java/lang/reflect/Field.html!>!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/ProtoUtils#getFilteredFieldList(java.lang.Class<?>,java.util.List<java.lang.String>)( clazz: https://developer.android.com/reference/java/lang/Class.html<*>!, targetFieldNames: (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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>! )` Returns a filtered view of a class's declared `https://developer.android.com/reference/java/lang/reflect/Field.html` list. |

## Public functions

### capitalizeFirstChar

```
java-static fun capitalizeFirstChar(aString: String!): String!
```

Capitalizes the first char of a String.

Examples: "espresso" -\> "Espresso", "Espresso" -\> "Espresso"

| Parameters |
|---|---|
| `aString: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | the String to capitalize |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | capitalized String or original String, if aString was empty |

### checkedGetEnumForProto

```
java-static fun <T : Enum?> checkedGetEnumForProto(protoEnumIndex: Int, enumClass: Class<T!>!): T!
```

Maps an enum proto message type to a internal representation enum type T.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-enum/index.html?>` | the generic type of the enum representation |
| `protoEnumIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the proto enum index of the value returned by the unwrapped proto message |
| `enumClass: https://developer.android.com/reference/java/lang/Class.html<T!>!` | the enum class to map against |

| Returns |
|---|---|
| `T!` | the enum constant for a proto enum index |

### getFilteredFieldList

```
java-static fun getFilteredFieldList(
    clazz: Class<*>!,
    targetFieldNames: (Mutable)List<String!>!
): (Mutable)List<Field!>!
```

Returns a filtered view of a class's declared `https://developer.android.com/reference/java/lang/reflect/Field.html` list.

| Parameters |
|---|---|
| `clazz: https://developer.android.com/reference/java/lang/Class.html<*>!` | the class to introspect |
| `targetFieldNames: (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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | the field names to filter from a class `https://developer.android.com/reference/java/lang/reflect/Field.html` list |

| Returns |
|---|---|
| `(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/java/lang/reflect/Field.html!>!` | a filtered list of class `https://developer.android.com/reference/java/lang/reflect/Field.html`s |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NoSuchFieldException.html` | if a field name does not exist in `clazz` |