org.fiolino.common.reflection.RegistryMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
General structure to easily create dynamic logic via MethodHandles and others.
package org.fiolino.common.reflection;
import java.lang.invoke.MethodHandles;
/**
* Created by kuli on 10.03.17.
*/
final class RegistryMapper implements LambdaRegistry {
private final Resettable registry;
private final T accessor;
RegistryMapper(Registry registry, Class lambdaType) {
this.registry = registry;
MethodHandles.Lookup lookup = MethodHandles.lookup();
accessor = Methods.lambdafy(lookup, registry.getAccessor(), lambdaType);
}
@Override
public T getAccessor() {
return accessor;
}
@Override
public void reset() {
registry.reset();
}
}