@Test public void testResolution() { ReflectionResolver resolver = new ReflectionResolver(); MustacheEngineBuilder.newBuilder().omitServiceLoaderConfigurationExtensions().addResolver(resolver).build(); Hammer hammer = new Hammer(); assertNull(resolver.resolve(null, "whatever", null)); assertNotNull(resolver.resolve(hammer, "age", null)); assertEquals(10, resolver.resolve(hammer, "age", null)); assertNull(resolver.resolve(hammer, "getAgeForName", null)); }
@Override public Object resolve(Object contextObject, String name, ResolutionContext context) { if (contextObject == null) { return null; } MemberWrapper wrapper; MemberKey key = MemberKey.newInstance(contextObject, name); if (memberCache != null) { wrapper = memberCache.get(key).orElse(null); } else { wrapper = findWrapper(key).orElse(null); } if (wrapper == null) { return null; } try { return wrapper.getValue(contextObject); } catch (Exception e) { throw new MustacheException( MustacheProblem.RENDER_REFLECT_INVOCATION_ERROR, e); } }
ReflectionResolver extends AbstractResolver { @Override public Object resolve(Object contextObject, String name, ResolutionContext context) { if (contextObject == null) { return null; } MemberWrapper wrapper; MemberKey key = MemberKey.newInstance(contextObject, name); if (memberCache != null) { wrapper = memberCache.get(key).orElse(null); } else { wrapper = findWrapper(key).orElse(null); } if (wrapper == null) { return null; } try { return wrapper.getValue(contextObject); } catch (Exception e) { throw new MustacheException( MustacheProblem.RENDER_REFLECT_INVOCATION_ERROR, e); } } }
ReflectionResolver extends AbstractResolver { @Override public Object resolve(Object contextObject, String name, ResolutionContext context) { if (contextObject == null) { return null; } MemberWrapper wrapper; MemberKey key = MemberKey.newInstance(contextObject, name); if (memberCache != null) { wrapper = memberCache.get(key).orElse(null); } else { wrapper = findWrapper(key).orElse(null); } if (wrapper == null) { return null; } try { return wrapper.getValue(contextObject); } catch (Exception e) { throw new MustacheException( MustacheProblem.RENDER_REFLECT_INVOCATION_ERROR, e); } } ReflectionResolver();  ReflectionResolver(int priority); }
ReflectionResolver extends AbstractResolver { @Override public Object resolve(Object contextObject, String name, ResolutionContext context) { if (contextObject == null) { return null; } MemberWrapper wrapper; MemberKey key = MemberKey.newInstance(contextObject, name); if (memberCache != null) { wrapper = memberCache.get(key).orElse(null); } else { wrapper = findWrapper(key).orElse(null); } if (wrapper == null) { return null; } try { return wrapper.getValue(contextObject); } catch (Exception e) { throw new MustacheException( MustacheProblem.RENDER_REFLECT_INVOCATION_ERROR, e); } } ReflectionResolver();  ReflectionResolver(int priority); @Override Object resolve(Object contextObject, String name,
            ResolutionContext context); @Override Hint createHint(Object contextObject, String name,
            ResolutionContext context); @Override void init(); @Override Set<ConfigurationKey> getConfigurationKeys(); void invalidateMemberCache(Predicate<Class<?>> predicate); }
ReflectionResolver extends AbstractResolver { @Override public Object resolve(Object contextObject, String name, ResolutionContext context) { if (contextObject == null) { return null; } MemberWrapper wrapper; MemberKey key = MemberKey.newInstance(contextObject, name); if (memberCache != null) { wrapper = memberCache.get(key).orElse(null); } else { wrapper = findWrapper(key).orElse(null); } if (wrapper == null) { return null; } try { return wrapper.getValue(contextObject); } catch (Exception e) { throw new MustacheException( MustacheProblem.RENDER_REFLECT_INVOCATION_ERROR, e); } } ReflectionResolver();  ReflectionResolver(int priority); @Override Object resolve(Object contextObject, String name,
            ResolutionContext context); @Override Hint createHint(Object contextObject, String name,
            ResolutionContext context); @Override void init(); @Override Set<ConfigurationKey> getConfigurationKeys(); void invalidateMemberCache(Predicate<Class<?>> predicate); static final int REFLECTION_RESOLVER_PRIORITY; static final String COMPUTING_CACHE_CONSUMER_ID; static final ConfigurationKey MEMBER_CACHE_MAX_SIZE_KEY; static final ConfigurationKey HINT_FALLBACK_ENABLED_KEY; static final String GET_PREFIX; static final String IS_PREFIX; }