public final class

ProtoUtils

extends Object
java.lang.Object
   ↳ androidx.test.espresso.remote.ProtoUtils

Class Overview

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

Summary

Public Methods
static String capitalizeFirstChar(String aString)
Capitalizes the first char of a String.
static <T extends Enum> T checkedGetEnumForProto(int protoEnumIndex, Class<T> enumClass)
Maps an enum proto message type to a internal representation enum type T.
static List<Field> getFilteredFieldList(Class<?> clazz, List<String> targetFieldNames)
Returns a filtered view of a class's declared Field list.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static String capitalizeFirstChar (String aString)

Capitalizes the first char of a String.

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

Parameters
aString String: the String to capitalize
Returns
String capitalized String or original String, if aString was empty

public static T checkedGetEnumForProto (int protoEnumIndex, Class<T> enumClass)

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

Parameters
protoEnumIndex int: the proto enum index of the value returned by the unwrapped proto message
enumClass Class: the enum class to map against
Returns
T the enum constant for a proto enum index

public static List<Field> getFilteredFieldList (Class<?> clazz, List<String> targetFieldNames)

Returns a filtered view of a class's declared Field list.

Parameters
clazz Class: the class to introspect
targetFieldNames List: the field names to filter from a class Field list
Returns
List<Field> a filtered list of class Fields
Throws
NoSuchFieldException if a field name does not exist in clazz