resolvePath static method

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

Resolves a JSON Pointer into a ZorphyLens over AgentSessionDocument.

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<AgentSessionDocument, Object?>? resolvePath(
  String pointer,
) {
  return switch (pointer) {
    '/id' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/id',
      get: (root) => root.id,
      set: (root, value) => root.copyWith(id: value as String),
    ),
    '/status' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/status',
      get: (root) => root.status,
      set: (root, value) =>
          root.copyWith(status: value as AgentSessionStatus),
    ),
    '/messages' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/messages',
      get: (root) => root.messages,
      set: (root, value) =>
          root.copyWith(messages: value as List<AgentMessage>?),
    ),
    '/toolCalls' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/toolCalls',
      get: (root) => root.toolCalls,
      set: (root, value) =>
          root.copyWith(toolCalls: value as List<AgentToolCall>?),
    ),
    '/activeTool' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/activeTool',
      get: (root) => root.activeTool,
      set: (root, value) => root.copyWith(activeTool: value as String?),
    ),
    '/turns' => ZorphyLens<AgentSessionDocument, Object?>(
      path: '/turns',
      get: (root) => root.turns,
      set: (root, value) => root.copyWith(turns: value as int?),
    ),
    _ => null,
  };
}