/** convert lucene document into instrument */
@SuppressWarnings("unchecked")
static <V extends Value<V>> DDF_Instrument instrumentDecode(
final Document doc) {
final DDF_InstrumentDo instrument = DDF_InstrumentProvider
.newInstrumentDDF();
for (final InstrumentField<?> field : CodecHelper.BASE) {
final String name = field.name();
final String value = doc.get(name);
if (!isValid(value)) {
continue;
}
instrument
.set((InstrumentField<V>) field, (V) decode(field, value));
}
for (final DDF_InstrumentField<?> field : CodecHelper.EXTRA) {
final String name = field.name();
final String value = doc.get(name);
if (!isValid(value)) {
continue;
}
instrument.set((DDF_InstrumentField<V>) field,
(V) decode(field, value));
}
return instrument;