# Class PartConverter

java.lang.Object
com.google.adk.a2a.converters.PartConverter

public final class PartConverter extends Object
Utility class for converting between Google GenAI Parts and A2A DataParts.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ARGS_KEY`
  `static final String`
  `CODE_KEY`
  `static final String`
  `ID_KEY`
  `static final String`
  `LANGUAGE_KEY`
  `static final String`
  `NAME_KEY`
  `static final String`
  `OUTCOME_KEY`
  `static final String`
  `OUTPUT_KEY`
  `static final String`
  `PARTIAL_ARGS_KEY`
  `static final String`
  `PARTS_KEY`
  `static final String`
  `RESPONSE_KEY`
  `static final String`
  `SCHEDULING_KEY`
  `static final String`
  `WILL_CONTINUE_KEY`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static io.a2a.spec.Part<?>`
  `fromGenaiPart(com.google.genai.types.Part part, boolean isPartial)`
  Convert a GenAI part into the A2A JSON representation.
  `static com.google.genai.types.Content`
  `messageToContent(io.a2a.spec.Message message)`
  Converts an A2A Message to a Google GenAI Content object.
  `static com.google.genai.types.Part`
  `remoteCallAsUserPart(String author, com.google.genai.types.Part part)`
  Converts a remote call part to a user part.
  `static com.google.genai.types.Part`
  `toGenaiPart(io.a2a.spec.Part<?> a2aPart)`
  Convert an A2A JSON part into a Google GenAI part representation.
  `static com.google.common.collect.ImmutableList<com.google.genai.types.Part>`
  `toGenaiParts(List<io.a2a.spec.Part<?>> a2aParts)`
  `static Optional<io.a2a.spec.TextPart>`
  `toTextPart(io.a2a.spec.Part<?> part)`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LANGUAGE_KEY

    public static final String LANGUAGE_KEY
    See Also:
      - Constant Field Values

  - ### OUTCOME_KEY

    public static final String OUTCOME_KEY
    See Also:
      - Constant Field Values

  - ### CODE_KEY

    public static final String CODE_KEY
    See Also:
      - Constant Field Values

  - ### OUTPUT_KEY

    public static final String OUTPUT_KEY
    See Also:
      - Constant Field Values

  - ### NAME_KEY

    public static final String NAME_KEY
    See Also:
      - Constant Field Values

  - ### ARGS_KEY

    public static final String ARGS_KEY
    See Also:
      - Constant Field Values

  - ### RESPONSE_KEY

    public static final String RESPONSE_KEY
    See Also:
      - Constant Field Values

  - ### ID_KEY

    public static final String ID_KEY
    See Also:
      - Constant Field Values

  - ### WILL_CONTINUE_KEY

    public static final String WILL_CONTINUE_KEY
    See Also:
      - Constant Field Values

  - ### PARTIAL_ARGS_KEY

    public static final String PARTIAL_ARGS_KEY
    See Also:
      - Constant Field Values

  - ### SCHEDULING_KEY

    public static final String SCHEDULING_KEY
    See Also:
      - Constant Field Values

  - ### PARTS_KEY

    public static final String PARTS_KEY
    See Also:
      - Constant Field Values

- ## Method Details

  - ### toTextPart

    public static Optional<io.a2a.spec.TextPart> toTextPart(io.a2a.spec.Part<?> part)

  - ### toGenaiPart

    public static com.google.genai.types.Part toGenaiPart(io.a2a.spec.Part<?> a2aPart)
    Convert an A2A JSON part into a Google GenAI part representation.

  - ### toGenaiParts

    public static com.google.common.collect.ImmutableList<com.google.genai.types.Part> toGenaiParts(List<io.a2a.spec.Part<?>> a2aParts)

  - ### messageToContent

    public static com.google.genai.types.Content messageToContent(io.a2a.spec.Message message)
    Converts an A2A Message to a Google GenAI Content object.
    Parameters:
      `message` - The A2A Message to convert.
    Returns:
      The converted Google GenAI Content object.

  - ### fromGenaiPart

    public static io.a2a.spec.Part<?> fromGenaiPart(com.google.genai.types.Part part, boolean isPartial)
    Convert a GenAI part into the A2A JSON representation.

  - ### remoteCallAsUserPart

    public static com.google.genai.types.Part remoteCallAsUserPart(String author, com.google.genai.types.Part part)
    Converts a remote call part to a user part.

    Events are rephrased as if a user was telling what happened in the session up to the point. E.g.

        For context:
        User said: Now help me with Z
        Agent A said: Agent B can help you with it!
        Agent B said: Agent C might know better.*

    Parameters:
      `author` - The author of the part.
      `part` - The part to convert.
    Returns:
      The converted part.