class ProtoUtils


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

Summary

Public functions

java-static String!

Capitalizes the first char of a String.

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

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

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

Returns a filtered view of a class's declared Field 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: String!

the String to capitalize

Returns
String!

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 : Enum?>

the generic type of the enum representation

protoEnumIndex: Int

the proto enum index of the value returned by the unwrapped proto message

enumClass: Class<T!>!

the enum class to map against

Returns
T!

the enum constant for a proto enum index

getFilteredFieldList

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

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

Parameters
clazz: Class<Any!>!

the class to introspect

targetFieldNames: (Mutable)List<String!>!

the field names to filter from a class Field list

Returns
(Mutable)List<Field!>!

a filtered list of class Fields

Throws
java.lang.NoSuchFieldException

if a field name does not exist in clazz