Class BetaCompactionBlock.ToolChange
-
- All Implemented Interfaces:
public final class BetaCompactionBlock.ToolChange
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaCompactionBlock.ToolChange.VisitorAn interface that defines how to map each variant of ToolChange to a value of type T.
public final classBetaCompactionBlock.ToolChange.Type
-
Method Summary
Modifier and Type Method Description final Optional<BetaResponseToolAdditionBlock>addition()An entry of a compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value.final Optional<BetaResponseToolRemovalBlock>removal()An entry of a compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew.final Optional<JsonValue>_json()final BetaCompactionBlock.ToolChange.Typetype()final BooleanisAddition()final BooleanisRemoval()final BetaResponseToolAdditionBlockasAddition()An entry of a compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value.final BetaResponseToolRemovalBlockasRemoval()An entry of a compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew.final <T extends Any> Taccept(BetaCompactionBlock.ToolChange.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaCompactionBlock.ToolChangevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaCompactionBlock.ToolChangeofAddition(BetaResponseToolAdditionBlock addition)An entry of a compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value.final static BetaCompactionBlock.ToolChangeofAddition(BetaResponseToolAdditionBlock.Tool tool)Returns an immutable instance of ToolChange whose ofAddition variant is built from the given required tool. final static BetaCompactionBlock.ToolChangeofAddition(BetaResponseToolChangeToolReference reference)Alias for calling ofAddition with BetaResponseToolAdditionBlock.Tool.ofReference(reference).final static BetaCompactionBlock.ToolChangeofAddition(BetaResponseToolChangeMcpToolReference mcpToolReference)Alias for calling ofAddition with BetaResponseToolAdditionBlock.Tool.ofMcpToolReference(mcpToolReference).final static BetaCompactionBlock.ToolChangeofAddition(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofAddition with BetaResponseToolAdditionBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).final static BetaCompactionBlock.ToolChangeofAddition(BetaToolChangeToolDefinition definition)Alias for calling ofAddition with BetaResponseToolAdditionBlock.Tool.ofDefinition(definition).final static BetaCompactionBlock.ToolChangeofRemoval(BetaResponseToolRemovalBlock removal)An entry of a compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew.final static BetaCompactionBlock.ToolChangeofRemoval(BetaResponseToolRemovalBlock.Tool tool)Returns an immutable instance of ToolChange whose ofRemoval variant is built from the given required tool. final static BetaCompactionBlock.ToolChangeofRemoval(BetaResponseToolChangeToolReference reference)Alias for calling ofRemoval with BetaResponseToolRemovalBlock.Tool.ofReference(reference).final static BetaCompactionBlock.ToolChangeofRemoval(BetaResponseToolChangeMcpToolReference mcpToolReference)Alias for calling ofRemoval with BetaResponseToolRemovalBlock.Tool.ofMcpToolReference(mcpToolReference).final static BetaCompactionBlock.ToolChangeofRemoval(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofRemoval with BetaResponseToolRemovalBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).-
-
Method Detail
-
addition
final Optional<BetaResponseToolAdditionBlock> addition()
An entry of a
compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value. Send it back unchanged.
-
removal
final Optional<BetaResponseToolRemovalBlock> removal()
An entry of a
compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew. Send it back unchanged.
-
type
final BetaCompactionBlock.ToolChange.Type type()
-
isAddition
final Boolean isAddition()
-
asAddition
final BetaResponseToolAdditionBlock asAddition()
An entry of a
compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value. Send it back unchanged.
-
asRemoval
final BetaResponseToolRemovalBlock asRemoval()
An entry of a
compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew. Send it back unchanged.
-
accept
final <T extends Any> T accept(BetaCompactionBlock.ToolChange.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 = toolChange.accept(new ToolChange.Visitor<Optional<String>>() { @Override public Optional<String> visitAddition(BetaResponseToolAdditionBlock addition) { return Optional.of(addition.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaCompactionBlock.ToolChange 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.
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaResponseToolAdditionBlock addition)
An entry of a
compactionblock'stool_changes: a tool the compacted range made available, as a reference to atoolsentry or MCP toolset, or as the tool definition in effect at the end of the range, by value. Send it back unchanged.
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaResponseToolAdditionBlock.Tool tool)
Returns an immutable instance of ToolChange whose ofAddition variant is built from the given required tool.
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaResponseToolChangeToolReference reference)
Alias for calling ofAddition with
BetaResponseToolAdditionBlock.Tool.ofReference(reference).
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaResponseToolChangeMcpToolReference mcpToolReference)
Alias for calling ofAddition with
BetaResponseToolAdditionBlock.Tool.ofMcpToolReference(mcpToolReference).
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofAddition with
BetaResponseToolAdditionBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).
-
ofAddition
final static BetaCompactionBlock.ToolChange ofAddition(BetaToolChangeToolDefinition definition)
Alias for calling ofAddition with
BetaResponseToolAdditionBlock.Tool.ofDefinition(definition).
-
ofRemoval
final static BetaCompactionBlock.ToolChange ofRemoval(BetaResponseToolRemovalBlock removal)
An entry of a
compactionblock'stool_changes: a tool of the request'stools(or an MCP tool or toolset) that the compacted range withdrew. Send it back unchanged.
-
ofRemoval
final static BetaCompactionBlock.ToolChange ofRemoval(BetaResponseToolRemovalBlock.Tool tool)
Returns an immutable instance of ToolChange whose ofRemoval variant is built from the given required tool.
-
ofRemoval
final static BetaCompactionBlock.ToolChange ofRemoval(BetaResponseToolChangeToolReference reference)
Alias for calling ofRemoval with
BetaResponseToolRemovalBlock.Tool.ofReference(reference).
-
ofRemoval
final static BetaCompactionBlock.ToolChange ofRemoval(BetaResponseToolChangeMcpToolReference mcpToolReference)
Alias for calling ofRemoval with
BetaResponseToolRemovalBlock.Tool.ofMcpToolReference(mcpToolReference).
-
ofRemoval
final static BetaCompactionBlock.ToolChange ofRemoval(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofRemoval with
BetaResponseToolRemovalBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).
-
-
-
-