Enum MessageRole
- All Implemented Interfaces:
Serializable, Comparable<MessageRole>, java.lang.constant.Constable
A type-safe enum representing the role of the author of a
ChatMessage.
This enum maps to the roles recognized by the Gemini API ("user", "model") and includes a "tool" role for function responses.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageRolefromString(String value) Parses a string role value into the corresponding enum constant.static MessageRoleReturns the enum constant of this type with the specified name.static MessageRole[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
USER
The user who is interacting with the model. -
MODEL
The model that is generating responses. -
TOOL
The tool that is providing function responses.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
fromString
Parses a string role value into the corresponding enum constant.This method is case-insensitive. If the provided value does not match any known role, it defaults to
USER.- Parameters:
value- The string value (e.g., "user", "model").- Returns:
- The matching MessageRole enum.
-
