public enum FactoryUtils extends Enum<FactoryUtils>
Modifier and Type | Class and Description |
---|---|
static interface |
FactoryUtils.FactoryInvoker<F,R>
Interface for invoking the factory.
|
Modifier and Type | Method and Description |
---|---|
static <R,F> R |
loadAndInvokeFactory(Class<F> factoryInterface,
FactoryUtils.FactoryInvoker<F,R> factoryInvoker,
java.util.function.Supplier<F> defaultProvider)
Loads all factories for the given class using the
ServiceLoader and attempts to
create an instance. |
static FactoryUtils |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static FactoryUtils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static FactoryUtils[] values()
for (FactoryUtils c : FactoryUtils.values()) System.out.println(c);
public static FactoryUtils valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static <R,F> R loadAndInvokeFactory(Class<F> factoryInterface, FactoryUtils.FactoryInvoker<F,R> factoryInvoker, java.util.function.Supplier<F> defaultProvider)
ServiceLoader
and attempts to
create an instance.R
- resource typeF
- factory typefactoryInterface
- factory interfacefactoryInvoker
- factory invokerdefaultProvider
- default factory providerRuntimeException
- if no or multiple resources could be instantiatedCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.