Package org.tomlj

Class GenericType<T>

java.lang.Object
org.tomlj.GenericType<T>
Type Parameters:
T - The type to bind to.

public abstract class GenericType<T> extends Object
A generic type to bind a table or array to, such as Map<String, Server> or List<Server>.

A Class cannot name a generic type, so a GenericType is created as an anonymous subclass that names it as its type argument:


 Map<String, Server> servers = table.as(new GenericType<Map<String, Server>>() {});
 

A class between the subclass and GenericType is allowed. Its type variables are replaced with the type arguments the subclass gives it, so with abstract class ServerMap<V> extends GenericType<Map<String, V>>, new ServerMap<Server>() {} names Map<String, Server>.

See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create a generic type that names the type argument given to GenericType by the subclass, resolved through any class between it and GenericType.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    final Type
    The type named.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GenericType

      protected GenericType()
      Create a generic type that names the type argument given to GenericType by the subclass, resolved through any class between it and GenericType.
      Throws:
      IllegalStateException - If no type argument is given to GenericType.
  • Method Details

    • type

      public final Type type()
      The type named.
      Returns:
      The type argument given to GenericType by the subclass.
    • toString

      public String toString()
      Overrides:
      toString in class Object