Class RPCGenerationCache
java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCGenerationCache
The cache for rpc implementation generations to prevent multiple generations for the same class.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA key for cache entries to distinct different ways of generating the same implementation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.github.benmanes.caffeine.cache.Cache<RPCGenerationCache.CacheKey, RPCInternalInstanceFactory> private final DefaultRPCFactory -
Constructor Summary
ConstructorsConstructorDescriptionRPCGenerationCache(@NonNull DefaultRPCFactory rpcFactory) Constructs a new rpc generation cache. -
Method Summary
Modifier and TypeMethodDescriptiongetOrGenerateImplementation(int generationFlags, @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender rpcSender, @NonNull RPCClassMetadata baseClassMeta) Gets an existing instance factory for the target class wrapped in the given target class metadata.(package private) @NonNull RPCInternalInstanceFactorygetOrGenerateImplementation(int generationFlags, @NonNull Class<?> senderTargetType, @NonNull RPCClassMetadata baseClassMeta) Gets an existing instance factory for the target class wrapped in the given target class metadata.
-
Field Details
-
cachedGeneratedImplementation
private final com.github.benmanes.caffeine.cache.Cache<RPCGenerationCache.CacheKey, RPCInternalInstanceFactory> cachedGeneratedImplementation -
rpcFactory
-
-
Constructor Details
-
RPCGenerationCache
Constructs a new rpc generation cache.- Parameters:
rpcFactory- the rpc factory that is associated with this generation cache.- Throws:
NullPointerException- if the given rpc factory is null.
-
-
Method Details
-
getOrGenerateImplementation
@NonNull @NonNull RPCInternalInstanceFactory getOrGenerateImplementation(int generationFlags, @NonNull @NonNull Class<?> senderTargetType, @NonNull @NonNull RPCClassMetadata baseClassMeta) Gets an existing instance factory for the target class wrapped in the given target class metadata. The generation process is triggered again if different generation flags are supplied for the same type.- Parameters:
generationFlags- the options to apply during class generation.baseClassMeta- the class meta for the class that is being generated.- Returns:
- an instance factory for the generated rpc api implementation.
- Throws:
NullPointerException- if the given base class meta is null.
-
getOrGenerateImplementation
@NonNull public @NonNull RPCInternalInstanceFactory getOrGenerateImplementation(int generationFlags, @NonNull @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender rpcSender, @NonNull @NonNull RPCClassMetadata baseClassMeta) Gets an existing instance factory for the target class wrapped in the given target class metadata. The generation process is triggered again if different generation flags are supplied for the same type.- Parameters:
generationFlags- the options to apply during class generation.rpcSender- the base rpc sender for the target class.baseClassMeta- the class meta for the class that is being generated.- Returns:
- an instance factory for the generated rpc api implementation.
- Throws:
NullPointerException- if the given rpc sender or base class meta is null.
-