Package org.bremersee.test.beans
Class SimpleObjectProvider<T>
- java.lang.Object
-
- org.bremersee.test.beans.SimpleObjectProvider<T>
-
- Type Parameters:
T
- the type parameter
- All Implemented Interfaces:
Iterable<T>
,org.springframework.beans.factory.ObjectFactory<T>
,org.springframework.beans.factory.ObjectProvider<T>
public class SimpleObjectProvider<T> extends Object implements org.springframework.beans.factory.ObjectProvider<T>
The simple object provider.
-
-
Constructor Summary
Constructors Constructor Description SimpleObjectProvider(T provides)
Instantiates a new simple object provider.SimpleObjectProvider(T provides, Consumer<T> dependencyConsumer)
Instantiates a new simple object provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getIfAvailable()
T
getIfUnique()
T
getObject()
T
getObject(Object... objects)
void
ifAvailable(Consumer<T> dependencyConsumer)
void
ifUnique(Consumer<T> dependencyConsumer)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SimpleObjectProvider
public SimpleObjectProvider(@Nullable T provides)
Instantiates a new simple object provider.- Parameters:
provides
- the provides
-
SimpleObjectProvider
public SimpleObjectProvider(@Nullable T provides, @Nullable Consumer<T> dependencyConsumer)
Instantiates a new simple object provider.If a dependency consumer is set, the given consumer will be invoked when
ObjectProvider.ifAvailable(Consumer)
orObjectProvider.ifUnique(Consumer)
is called.- Parameters:
provides
- the providesdependencyConsumer
- the dependency consumer
-
-
Method Detail
-
getObject
@NonNull public T getObject(@NonNull Object... objects) throws org.springframework.beans.BeansException
- Specified by:
getObject
in interfaceorg.springframework.beans.factory.ObjectProvider<T>
- Throws:
org.springframework.beans.BeansException
-
ifAvailable
public void ifAvailable(@NonNull Consumer<T> dependencyConsumer) throws org.springframework.beans.BeansException
- Specified by:
ifAvailable
in interfaceorg.springframework.beans.factory.ObjectProvider<T>
- Throws:
org.springframework.beans.BeansException
-
ifUnique
public void ifUnique(@NonNull Consumer<T> dependencyConsumer) throws org.springframework.beans.BeansException
- Specified by:
ifUnique
in interfaceorg.springframework.beans.factory.ObjectProvider<T>
- Throws:
org.springframework.beans.BeansException
-
getIfAvailable
public T getIfAvailable() throws org.springframework.beans.BeansException
- Specified by:
getIfAvailable
in interfaceorg.springframework.beans.factory.ObjectProvider<T>
- Throws:
org.springframework.beans.BeansException
-
getIfUnique
public T getIfUnique() throws org.springframework.beans.BeansException
- Specified by:
getIfUnique
in interfaceorg.springframework.beans.factory.ObjectProvider<T>
- Throws:
org.springframework.beans.BeansException
-
-