com.github.jknack.handlebars.context
Class MethodValueResolver

java.lang.Object
  extended by com.github.jknack.handlebars.context.MemberValueResolver<Method>
      extended by com.github.jknack.handlebars.context.MethodValueResolver
All Implemented Interfaces:
ValueResolver
Direct Known Subclasses:
JavaBeanValueResolver

public class MethodValueResolver
extends MemberValueResolver<Method>

A specialization of MemberValueResolver with lookup and invocation support for Method. It matches a public method.

Since:
0.1.1
Author:
edgar.espina

Field Summary
static ValueResolver INSTANCE
          The default instance.
 
Fields inherited from interface com.github.jknack.handlebars.ValueResolver
UNRESOLVED, VALUE_RESOLVERS
 
Constructor Summary
MethodValueResolver()
           
 
Method Summary
protected  Object invokeMember(Method member, Object context)
          Invoke the member in the given context.
 boolean matches(Method method, String name)
          True, if the member matches the one we look for.
protected  String memberName(Method member)
          Get the name for the given member.
protected  Set<Method> members(Class<?> clazz)
          List all the possible members for the given class.
protected  void members(Class<?> clazz, Set<Method> members)
          Collect all the method from the given class.
 
Methods inherited from class com.github.jknack.handlebars.context.MemberValueResolver
find, isPrivate, isProtected, isPublic, isStatic, membersFromCache, propertySet, resolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final ValueResolver INSTANCE
The default instance.

Constructor Detail

MethodValueResolver

public MethodValueResolver()
Method Detail

matches

public boolean matches(Method method,
                       String name)
Description copied from class: MemberValueResolver
True, if the member matches the one we look for.

Specified by:
matches in class MemberValueResolver<Method>
Parameters:
method - The class Member.
name - The attribute's name.
Returns:
True, if the member matches the one we look for.

invokeMember

protected Object invokeMember(Method member,
                              Object context)
Description copied from class: MemberValueResolver
Invoke the member in the given context.

Specified by:
invokeMember in class MemberValueResolver<Method>
Parameters:
member - The class member.
context - The context object.
Returns:
The resulting value.

members

protected Set<Method> members(Class<?> clazz)
Description copied from class: MemberValueResolver
List all the possible members for the given class.

Specified by:
members in class MemberValueResolver<Method>
Parameters:
clazz - The base class.
Returns:
All the possible members for the given class.

members

protected void members(Class<?> clazz,
                       Set<Method> members)
Collect all the method from the given class.

Parameters:
clazz - The base class.
members - The members result set.

memberName

protected String memberName(Method member)
Description copied from class: MemberValueResolver
Get the name for the given member.

Specified by:
memberName in class MemberValueResolver<Method>
Parameters:
member - A class member.
Returns:
The member's name.


Copyright © 2012. All Rights Reserved.