Class MemberValueResolver<M extends Member>

java.lang.Object
com.github.jknack.handlebars.context.MemberValueResolver<M>
Type Parameters:
M - The member type.
All Implemented Interfaces:
ValueResolver
Direct Known Subclasses:
FieldValueResolver, MethodValueResolver

public abstract class MemberValueResolver<M extends Member> extends Object implements ValueResolver
A specialization of ValueResolver that is built on top of reflections API. It use an internal cache for saving members.
Since:
0.1.1
  • Constructor Details

    • MemberValueResolver

      public MemberValueResolver()
  • Method Details

    • resolve

      public final Object resolve(Object context, String name)
      Description copied from interface: ValueResolver
      Resolve the attribute's name in the context object. If a ValueResolver.UNRESOLVED is returned, the context stack will continue with the next value resolver in the chain.
      Specified by:
      resolve in interface ValueResolver
      Parameters:
      context - The context object. Not null.
      name - The attribute's name. Not null.
      Returns:
      A ValueResolver.UNRESOLVED is returned, the context stack will continue with the next value resolver in the chain. Otherwise, it returns the associated value.
    • resolve

      public Object resolve(Object context)
      Description copied from interface: ValueResolver
      Resolve the the context object by optionally converting the value if necessary. If a ValueResolver.UNRESOLVED is returned, the context stack will continue with the next value resolver in the chain.
      Specified by:
      resolve in interface ValueResolver
      Parameters:
      context - The context object. Not null.
      Returns:
      A ValueResolver.UNRESOLVED is returned, the context stack will continue with the next value resolver in the chain. Otherwise, it returns the associated value.
    • matches

      public abstract boolean matches(M member, String name)
      True, if the member matches the one we look for.
      Parameters:
      member - The class Member.
      name - The attribute's name.
      Returns:
      True, if the member matches the one we look for.
    • propertySet

      public Set<Map.Entry<String,Object>> propertySet(Object context)
      Description copied from interface: ValueResolver
      List all the properties and their values for the given object.
      Specified by:
      propertySet in interface ValueResolver
      Parameters:
      context - The context object. Not null.
      Returns:
      All the properties and their values for the given object.