public interface ValueRenderer extends ValueCoder
An extended ValueCoder
that can populate a supplied
Object
with data that was formerly written to a Value
by
the ValueCoder
.
A ValueRenderer
implements an additional method called
render(com.persistit.Value, java.lang.Object, java.lang.Class<?>, com.persistit.encoding.CoderContext)
that populates a supplied target object rather than creating
a new object instance. The application provides the mutable target object to
Value.get(Object)
.
A ValueRenderer
can implement an application-level contract to
recover a limited set of fields from an encoded Value
or to
populate a generic target object that might be suitable for utility display
purposes. For example, suppose there is a complex Person
class
with many fields that refer to other objects. Deserializing and populating
all the fields of such a Person
object might not be appropriate
in an area of the application that merely needs to display a list of names.
To avoid completely deserializing numerous Person
objects, the
application could register a ValueRenderer
implementation that
knows how to decode a serialized Person
into a
PersonListData
object. To do so it would Value.get()
the
desired interior fields of the encoded Person
and
Value.skip()
the other fields.
Modifier and Type | Method and Description |
---|---|
void |
render(Value value,
Object target,
Class<?> clazz,
CoderContext context)
Populates the state of the supplied (mutable) target
Object
by decoding the supplied Value . |
get, put
void render(Value value, Object target, Class<?> clazz, CoderContext context) throws ConversionException
Populates the state of the supplied (mutable) target Object
by decoding the supplied Value
. This method will be called
only if this ValueRenderer
has been registered with the
current CoderManager
to encode objects having the supplied
Class
value. Persistit will never call this method to decode
a value that was null
when written because null values are
handled by built-in encoding logic.
value
- The Value
from which interior fields of the
object are to be retrievedtarget
- The object into which the decoded value is to be writtenclazz
- The class of the object that was originally encoded into
Value.context
- An arbitrary object that can optionally be supplied by the
application to convey an application-specific context for the
operation. (See CoderContext
.) The default value is
null
.ConversionException
Copyright © 2025 Open Identity Platform Community. All rights reserved.