Class BetaMessageParam
-
- All Implemented Interfaces:
public final class BetaMessageParam
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaMessageParam.VisitorAn interface that defines how to map each variant of BetaMessageParam to a value of type T.
public final classBetaMessageParam.Role
-
Method Summary
Modifier and Type Method Description final Optional<BetaUserMessageParam>user()final Optional<BetaAssistantMessageParam>assistant()final Optional<BetaSystemMessageParam>system()final Optional<JsonValue>_json()final BetaMessageParam.Rolerole()final Optional<BetaMessageContentParam>content()final BooleanisUser()final BooleanisAssistant()final BooleanisSystem()final BetaUserMessageParamasUser()final BetaAssistantMessageParamasAssistant()final BetaSystemMessageParamasSystem()final <T extends Any> Taccept(BetaMessageParam.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaMessageParamvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaMessageParamofUser(BetaUserMessageParam user)final static BetaMessageParamofUser(BetaMessageContentParam content)Returns an immutable instance of BetaMessageParam whose ofUser variant is built from the given required content. final static BetaMessageParamofUser(String string)Alias for calling ofUser with BetaMessageContentParam.ofString(string).final static BetaMessageParamofUserOfContentBlockParams(List<BetaContentBlockParam> contentBlockParams)Alias for calling ofUser with BetaMessageContentParam.ofContentBlockParams(contentBlockParams).final static BetaMessageParamofAssistant(BetaAssistantMessageParam assistant)final static BetaMessageParamofAssistant(BetaMessageContentParam content)Returns an immutable instance of BetaMessageParam whose ofAssistant variant is built from the given required content. final static BetaMessageParamofAssistant(String string)Alias for calling ofAssistant with BetaMessageContentParam.ofString(string).final static BetaMessageParamofAssistantOfContentBlockParams(List<BetaContentBlockParam> contentBlockParams)Alias for calling ofAssistant with BetaMessageContentParam.ofContentBlockParams(contentBlockParams).final static BetaMessageParamofSystem(BetaSystemMessageParam system)final static BetaMessageParamofSystem(BetaSystemMessageParam.Content content)Returns an immutable instance of BetaMessageParam whose ofSystem variant is built from the given required content. final static BetaMessageParamofSystem(String string)Alias for calling ofSystem with BetaSystemMessageParam.Content.ofString(string).final static BetaMessageParamofSystemOfBlocks(List<BetaSystemMessageParam.Content.SystemMessageContentBlock> blocks)Alias for calling ofSystem with BetaSystemMessageParam.Content.ofBlocks(blocks).-
-
Method Detail
-
user
final Optional<BetaUserMessageParam> user()
-
assistant
final Optional<BetaAssistantMessageParam> assistant()
-
system
final Optional<BetaSystemMessageParam> system()
-
role
final BetaMessageParam.Role role()
-
content
final Optional<BetaMessageContentParam> content()
-
isAssistant
final Boolean isAssistant()
-
asUser
final BetaUserMessageParam asUser()
-
asAssistant
final BetaAssistantMessageParam asAssistant()
-
asSystem
final BetaSystemMessageParam asSystem()
-
accept
final <T extends Any> T accept(BetaMessageParam.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = betaMessageParam.accept(new BetaMessageParam.Visitor<Optional<String>>() { @Override public Optional<String> visitUser(BetaUserMessageParam user) { return Optional.of(user.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaMessageParam validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofUser
final static BetaMessageParam ofUser(BetaUserMessageParam user)
-
ofUser
final static BetaMessageParam ofUser(BetaMessageContentParam content)
Returns an immutable instance of BetaMessageParam whose ofUser variant is built from the given required content.
-
ofUser
final static BetaMessageParam ofUser(String string)
Alias for calling ofUser with
BetaMessageContentParam.ofString(string).
-
ofUserOfContentBlockParams
final static BetaMessageParam ofUserOfContentBlockParams(List<BetaContentBlockParam> contentBlockParams)
Alias for calling ofUser with
BetaMessageContentParam.ofContentBlockParams(contentBlockParams).
-
ofAssistant
final static BetaMessageParam ofAssistant(BetaAssistantMessageParam assistant)
-
ofAssistant
final static BetaMessageParam ofAssistant(BetaMessageContentParam content)
Returns an immutable instance of BetaMessageParam whose ofAssistant variant is built from the given required content.
-
ofAssistant
final static BetaMessageParam ofAssistant(String string)
Alias for calling ofAssistant with
BetaMessageContentParam.ofString(string).
-
ofAssistantOfContentBlockParams
final static BetaMessageParam ofAssistantOfContentBlockParams(List<BetaContentBlockParam> contentBlockParams)
Alias for calling ofAssistant with
BetaMessageContentParam.ofContentBlockParams(contentBlockParams).
-
ofSystem
final static BetaMessageParam ofSystem(BetaSystemMessageParam system)
-
ofSystem
final static BetaMessageParam ofSystem(BetaSystemMessageParam.Content content)
Returns an immutable instance of BetaMessageParam whose ofSystem variant is built from the given required content.
-
ofSystem
final static BetaMessageParam ofSystem(String string)
Alias for calling ofSystem with
BetaSystemMessageParam.Content.ofString(string).
-
ofSystemOfBlocks
final static BetaMessageParam ofSystemOfBlocks(List<BetaSystemMessageParam.Content.SystemMessageContentBlock> blocks)
Alias for calling ofSystem with
BetaSystemMessageParam.Content.ofBlocks(blocks).
-
-
-
-