resolvePath static method

ZorphyLens<AgentToolCall, Object?>? resolvePath(
  1. String pointer
)

Resolves a JSON Pointer into a ZorphyLens over AgentToolCall.

One switch step per segment, so a pointer costs O(depth) — no regex, no mirrors, no reflective lookup.

A pointer this node does not carry answers null.

Implementation

static ZorphyLens<AgentToolCall, Object?>? resolvePath(String pointer) {
  return switch (pointer) {
    '/name' => ZorphyLens<AgentToolCall, Object?>(
      path: '/name',
      get: (root) => root.name,
      set: (root, value) => root.copyWith(name: value as String),
    ),
    '/turn' => ZorphyLens<AgentToolCall, Object?>(
      path: '/turn',
      get: (root) => root.turn,
      set: (root, value) => root.copyWith(turn: value as int),
    ),
    '/outcome' => ZorphyLens<AgentToolCall, Object?>(
      path: '/outcome',
      get: (root) => root.outcome,
      set: (root, value) => root.copyWith(outcome: value as ToolCallOutcome?),
    ),
    '/summary' => ZorphyLens<AgentToolCall, Object?>(
      path: '/summary',
      get: (root) => root.summary,
      set: (root, value) => root.copyWith(summary: value as String?),
    ),
    _ => null,
  };
}