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 ofValueResolver
that 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 boolean
matches(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.Object
resolve(java.lang.Object context)
Resolve the the context object by optionally converting the value if necessary.java.lang.Object
resolve(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:ValueResolver
Resolve the attribute's name in the context object. If aValueResolver.UNRESOLVED
is returned, thecontext stack
will continue with the next value resolver in the chain.- Specified by:
resolve
in interfaceValueResolver
- Parameters:
context
- The context object. Not null.name
- The attribute's name. Not null.- Returns:
- A
ValueResolver.UNRESOLVED
is returned, thecontext stack
will 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:ValueResolver
Resolve the the context object by optionally converting the value if necessary. If aValueResolver.UNRESOLVED
is returned, thecontext stack
will continue with the next value resolver in the chain.- Specified by:
resolve
in interfaceValueResolver
- Parameters:
context
- The context object. Not null.- Returns:
- A
ValueResolver.UNRESOLVED
is returned, thecontext stack
will 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:ValueResolver
List all the properties and their values for the given object.- Specified by:
propertySet
in interfaceValueResolver
- Parameters:
context
- The context object. Not null.- Returns:
- All the properties and their values for the given object.
-
-