Class OptionalWireProvider<F>

java.lang.Object
dev.wyck.factory.WireProvider<@NonNull F>
dev.wyck.factory.OptionalWireProvider<F>
Type Parameters:
F - the type of the factory

@NullUnmarked public final class OptionalWireProvider<F> extends WireProvider<@NonNull F>
A WireProvider that returns null if the factory does not exist.
Since:
2.1.0
  • Method Details

    • create

      @AsOf("2.1.0") public static <F> @NonNull OptionalWireProvider<@NonNull F> create(@NonNull String classNameTemplate)
      Creates a new NullableWireProvider that reflectively instantiates the named class if no provider has been explicitly set.
    • empty

      @AsOf("2.1.0") public static <F> @NonNull OptionalWireProvider<@NonNull F> empty()
      Creates a new NullableWireProvider that does not reflectively instantiate anything. The provider is null until WireProvider.setProvider(Class, F) is called explicitly. Useful when the target class has side effects in its constructor that should only run after the host plugin has explicitly wired itself up.
    • get

      @AsOf("2.1.0") public F get()
      Gets the factory instance.
      Overrides:
      get in class WireProvider<@NonNull F>
      Returns:
      the factory instance, or null if the factory does not exist
      Since:
      2.1.0
    • optional

      public @NonNull Optional<F> optional()