Class Protocol.Type<T extends Protocol>

  • 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 Detail

      • 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 Detail

      • 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
      • hashCode

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

        public static <T extends ProtocolProtocol.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