Class Protocol.Type<T extends Protocol>

java.lang.Object
org.praxislive.core.Protocol.Type<T>
Type Parameters:
T - class of protocol
Enclosing interface:
Protocol

public static class Protocol.Type<T extends Protocol> extends Object
A protocol type registration, allowing protocols to be discovered by class or name. Additional types may be registered using Protocol.TypeProvider.
  • Constructor Details

    • Type

      public Type(Class<T> cls)
      Construct a type for the given Protocol class. The name will be the simple name of the class.
      Parameters:
      cls - Protocol class
  • Method Details

    • asClass

      public Class<T> asClass()
      Access the class of the Protocol type.
      Returns:
      class
    • name

      public String name()
      Access the name of the Protocol type.
      Returns:
      name
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • of

      public static <T extends Protocol> Protocol.Type<T> of(Class<T> cls)
      Lookup the Protocol type of the provided class. The type must be registered.
      Type Parameters:
      T - class type
      Parameters:
      cls - class
      Returns:
      type
    • fromName

      public static Optional<Protocol.Type<? extends Protocol>> fromName(String name)
      Lookup the Protocol type by name. If not registered an empty optional is returned.
      Parameters:
      name - protocol name
      Returns:
      optional of type