Class RuntimeCapability.Builder<T>

  • Type Parameters:
    T - the type of the runtime API object exposed by the capability
    Enclosing class:
    RuntimeCapability<T>

    public static class RuntimeCapability.Builder<T>
    extends Object
    Builder for a RuntimeCapability.
    • Method Detail

      • of

        public static RuntimeCapability.Builder<Void> of​(String name)
        Create a builder for a non-dynamic capability with no custom runtime API.
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        Returns:
        the builder
      • of

        public static RuntimeCapability.Builder<Void> of​(String name,
                                                         boolean dynamic)
        Create a builder for a possibly dynamic capability with no custom runtime API.
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        dynamic - true if the capability is a base capability for dynamically named capabilities
        Returns:
        the builder
      • of

        public static RuntimeCapability.Builder<Void> of​(String name,
                                                         Class<?> serviceValueType)
        Create a builder for a non-dynamic capability that installs a service with the given value type.
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        serviceValueType - the value type of the service installed by the capability
        Returns:
        the builder
      • of

        public static RuntimeCapability.Builder<Void> of​(String name,
                                                         boolean dynamic,
                                                         Class<?> serviceValueType)
        Create a builder for a possibly dynamic capability that installs a service with the given value type.
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        dynamic - true if the capability is a base capability for dynamically named capabilities
        serviceValueType - the value type of the service installed by the capability
        Returns:
        the builder
      • of

        public static <T> RuntimeCapability.Builder<T> of​(String name,
                                                          T runtimeAPI)
        Create a builder for a non-dynamic capability that provides the given custom runtime API.
        Type Parameters:
        T - the type of the runtime API object exposed by the capability
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        runtimeAPI - the custom API implementation exposed by the capability
        Returns:
        the builder
      • of

        public static <T> RuntimeCapability.Builder<T> of​(String name,
                                                          boolean dynamic,
                                                          T runtimeAPI)
        Create a builder for a possibly dynamic capability that provides the given custom runtime API.
        Type Parameters:
        T - the type of the runtime API object exposed by the capability
        Parameters:
        name - the name of the capability. Cannot be null or empty.
        dynamic - true if the capability is a base capability for dynamically named capabilities
        runtimeAPI - the custom API implementation exposed by the capability
        Returns:
        the builder
      • setServiceType

        public RuntimeCapability.Builder<T> setServiceType​(Class<?> type)
        Sets that the capability installs a service with the given value type.
        Parameters:
        type - the value type of the service installed by the capability. May be null
        Returns:
        the builder
      • addRequirements

        public RuntimeCapability.Builder<T> addRequirements​(String... requirements)
        Adds the names of other capabilities that this capability requires. The requirement for these capabilities will automatically be registered when this capability is registered.
        Parameters:
        requirements - the capability names
        Returns:
        the builder
      • setAllowMultipleRegistrations

        public RuntimeCapability.Builder<T> setAllowMultipleRegistrations​(boolean allowMultipleRegistrations)
        Sets whether this capability can be registered at more than one point within the same overall scope.
        Parameters:
        allowMultipleRegistrations - true if the capability can legally be registered in more than one location in the same scope; false if an attempt to do this should result in an exception
        Returns:
        the builder
      • build

        public RuntimeCapability<T> build()
        Builds the capability.
        Returns:
        the capability. Will not return null