
org.snapscript.platform.standard.MethodInvocationResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.platform.standard;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.snapscript.core.type.Type;
import org.snapscript.core.function.Invocation;
import org.snapscript.platform.InvocationCache;
import org.snapscript.platform.InvocationCacheTable;
public class MethodInvocationResolver {
private final InvocationCacheTable table;
private final MethodProxyBuilder builder;
public MethodInvocationResolver() {
this.table = new InvocationCacheTable();
this.builder = new MethodProxyBuilder();
}
public Invocation resolveSuperMethod(Type real, Method method) {
InvocationCache cache = table.get(real);
Invocation invocation = cache.fetch(method);
if(invocation == null) {
invocation = builder.createSuperMethod(method);
cache.cache(method, invocation);
}
return invocation;
}
public Invocation resolveMethod(Method method) {
return new DelegateMethodInvocation(method);
}
public Invocation resolveConstructor(Constructor constructor) {
return new DelegateConstructorInvocation(constructor);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy