Class CachingGeneratingDelegateFactory
java.lang.Object
ru.progrm_jarvis.javacommons.delegate.CachingGeneratingDelegateFactory
- All Implemented Interfaces:
DelegateFactory
- Direct Known Subclasses:
AsmDelegateFactory
Base for implementing
delegate factory
using internal CachingGeneratingDelegateFactory.DelegateWrapperFactory cached for each unique type.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceDelegate-wrapper factory responsible for creating delegate wrappers based on the specified supplier. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull Cache<@NotNull Class<?>,@NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<?>> Cache ofdelegate-wrapper factoriesby wrapped types -
Constructor Summary
ConstructorsConstructorDescriptionCachingGeneratingDelegateFactory(@NonNull Cache<@NotNull Class<?>, @NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<?>> factories) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <T> @NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<T>createFactory(@NotNull Class<T> targetType) Creates adelegate-wrapper factoryfot the given type.<T> TcreateWrapper(@NonNull Class<T> targetType, @NonNull Supplier<T> supplier) Creates a delegating wrapper of the given type using the providedSupplierfor its backend.
-
Field Details
-
factories
@NonNull protected final @NonNull Cache<@NotNull Class<?>,@NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<?>> factoriesCache ofdelegate-wrapper factoriesby wrapped types
-
-
Constructor Details
-
CachingGeneratingDelegateFactory
public CachingGeneratingDelegateFactory(@NonNull @NonNull Cache<@NotNull Class<?>, @NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<?>> factories)
-
-
Method Details
-
createFactory
@NotNull protected abstract <T> @NotNull CachingGeneratingDelegateFactory.DelegateWrapperFactory<T> createFactory(@NotNull @NotNull Class<T> targetType) Creates adelegate-wrapper factoryfot the given type.- Type Parameters:
T- created wrapper's type- Parameters:
targetType- type of the wrapper to be created by the factory- Returns:
- delegate-wrapper factory for the given type
-
createWrapper
@NotNull public <T> T createWrapper(@NonNull @NonNull Class<T> targetType, @NonNull @NonNull Supplier<T> supplier) Description copied from interface:DelegateFactoryCreates a delegating wrapper of the given type using the providedSupplierfor its backend.- Specified by:
createWrapperin interfaceDelegateFactory- Type Parameters:
T- type of implemented wrapper- Parameters:
targetType- type of implemented wrappersupplier- supplier to handle access to the underlying object- Returns:
- created delegating wrapper for the given supplier
-