Class ResolutionCache
- java.lang.Object
-
- com.tonic.analysis.execution.resolve.ResolutionCache
-
public class ResolutionCache extends Object
Concurrent memoization cache for class, method, field, and assignability lookups.
-
-
Constructor Summary
Constructors Constructor Description ResolutionCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Empties all four caches.BooleangetAssignability(String key, Supplier<Boolean> computer)Returns the cached assignability verdict, computing and caching it on a miss.ClassFilegetClass(String name, Supplier<ClassFile> loader)Returns the cached class, loading and caching it on a miss.ResolvedFieldgetField(String key, Supplier<ResolvedField> resolver)Returns the cached field resolution, resolving and caching it on a miss.ResolvedMethodgetMethod(String key, Supplier<ResolvedMethod> resolver)Returns the cached method resolution, resolving and caching it on a miss.intsize()
-
-
-
Method Detail
-
getClass
public ClassFile getClass(String name, Supplier<ClassFile> loader)
Returns the cached class, loading and caching it on a miss.- Parameters:
name- cache keyloader- supplier invoked on a miss- Returns:
- the cached or newly loaded class file
-
getMethod
public ResolvedMethod getMethod(String key, Supplier<ResolvedMethod> resolver)
Returns the cached method resolution, resolving and caching it on a miss.- Parameters:
key- cache keyresolver- supplier invoked on a miss- Returns:
- the cached or newly resolved method
-
getField
public ResolvedField getField(String key, Supplier<ResolvedField> resolver)
Returns the cached field resolution, resolving and caching it on a miss.- Parameters:
key- cache keyresolver- supplier invoked on a miss- Returns:
- the cached or newly resolved field
-
getAssignability
public Boolean getAssignability(String key, Supplier<Boolean> computer)
Returns the cached assignability verdict, computing and caching it on a miss.- Parameters:
key- cache keycomputer- supplier invoked on a miss- Returns:
- the cached or newly computed verdict
-
clear
public void clear()
Empties all four caches.
-
size
public int size()
- Returns:
- the total number of entries across all caches
-
-