ProtoUtils

public final class ProtoUtils
extends Object

java.lang.Object
   ↳ android.support.test.espresso.remote.ProtoUtils


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.

Inherited methods

From class java.lang.Object

Public methods

capitalizeFirstChar

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

checkedGetEnumForProto

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

getFilteredFieldList

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