Class MemberValueResolver<M extends java.lang.reflect.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 java.lang.reflect.Member> extends java.lang.Object implements ValueResolver
A specialization ofValueResolverthat is built on top of reflections API. It use an internal cache for savingmembers.- Since:
- 0.1.1
-
-
Field Summary
-
Fields inherited from interface com.github.jknack.handlebars.ValueResolver
UNRESOLVED
-
-
Constructor Summary
Constructors Constructor Description MemberValueResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanmatches(M member, java.lang.String name)True, if the member matches the one we look for.java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>propertySet(java.lang.Object context)List all the properties and their values for the given object.java.lang.Objectresolve(java.lang.Object context)Resolve the the context object by optionally converting the value if necessary.java.lang.Objectresolve(java.lang.Object context, java.lang.String name)Resolve the attribute's name in the context object.
-
-
-
Method Detail
-
resolve
public final java.lang.Object resolve(java.lang.Object context, java.lang.String name)Description copied from interface:ValueResolverResolve the attribute's name in the context object. If aValueResolver.UNRESOLVEDis returned, thecontext stackwill continue with the next value resolver in the chain.- Specified by:
resolvein interfaceValueResolver- Parameters:
context- The context object. Not null.name- The attribute's name. Not null.- Returns:
- A
ValueResolver.UNRESOLVEDis returned, thecontext stackwill continue with the next value resolver in the chain. Otherwise, it returns the associated value.
-
resolve
public java.lang.Object resolve(java.lang.Object context)
Description copied from interface:ValueResolverResolve the the context object by optionally converting the value if necessary. If aValueResolver.UNRESOLVEDis returned, thecontext stackwill continue with the next value resolver in the chain.- Specified by:
resolvein interfaceValueResolver- Parameters:
context- The context object. Not null.- Returns:
- A
ValueResolver.UNRESOLVEDis returned, thecontext stackwill continue with the next value resolver in the chain. Otherwise, it returns the associated value.
-
matches
public abstract boolean matches(M member, java.lang.String name)
True, if the member matches the one we look for.- Parameters:
member- The classMember.name- The attribute's name.- Returns:
- True, if the member matches the one we look for.
-
propertySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> propertySet(java.lang.Object context)
Description copied from interface:ValueResolverList all the properties and their values for the given object.- Specified by:
propertySetin interfaceValueResolver- Parameters:
context- The context object. Not null.- Returns:
- All the properties and their values for the given object.
-
-