Class TypeRef<T>

java.lang.Object
io.modelcontextprotocol.json.TypeRef<T>

public abstract class TypeRef<T> extends Object
Captures generic type information at runtime for parameterized JSON (de)serialization. Usage: TypeRef<List> ref = new TypeRef<>(){};
  • Constructor Details

    • TypeRef

      protected TypeRef()
      Constructs a new TypeRef instance, capturing the generic type information of the subclass. This constructor should be called from an anonymous subclass to capture the actual type arguments. For example:
       TypeRef<List<Foo>> ref = new TypeRef<>(){};
       
      Throws:
      IllegalStateException - if TypeRef is not subclassed with actual type information
  • Method Details

    • getType

      public Type getType()
      Returns the captured type information.
      Returns:
      the Type representing the actual type argument captured by this TypeRef instance