JBBPFieldStruct extends JBBPAbstractField implements JBBPFieldFinder { @SafeVarargs public final <T> T mapTo(final String path, final T instance, final Function<Class<?>, Object>... instantiators) { return JBBPMapper.map(this, path, instance, instantiators); } JBBPFieldStruct(final JBBPNamedFieldInfo name, final JBBPAbstractField[] fields);  JBBPFieldStruct(final JBBPNamedFieldInfo name, final List<JBBPAbstractField> fields); JBBPAbstractField[] getArray(); @Override JBBPAbstractField findFieldForPath(final String fieldPath); @Override JBBPAbstractField findFieldForName(final String name); @Override T findFieldForType(final Class<T> fieldType); @Override T findFirstFieldForType(final Class<T> fieldType); @Override T findLastFieldForType(final Class<T> fieldType); @Override T findFieldForNameAndType(final String fieldName, final Class<T> fieldType); @Override boolean nameExists(final String fieldName); @Override boolean pathExists(final String fieldPath); @Override T findFieldForPathAndType(final String fieldPath, final Class<T> fieldType); @SafeVarargs final T mapTo(final String path, final T instance, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final String path, final T instance, final int flags, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final String path, final T instance, final JBBPMapperCustomFieldProcessor customFieldProcessor, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final String path, final T instance, final JBBPMapperCustomFieldProcessor customFieldProcessor, final int flags, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final T objectToMap, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final T instance, final int flags, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final T instance, final JBBPMapperCustomFieldProcessor customFieldProcessor, final Function<Class<?>, Object>... instantiators); @SafeVarargs final T mapTo(final T objectToMap, final JBBPMapperCustomFieldProcessor customFieldProcessor, final int flags, final Function<Class<?>, Object>... instantiators); @Override String getTypeAsString();  }
@Test public void testMapTo_Class() throws Exception { final ClassTestMapToClass mapped = JBBPParser.prepare("byte a; byte b; byte c;").parse(new byte[] {1, 2, 3}).mapTo(new ClassTestMapToClass()); assertEquals(1, mapped.a); assertEquals(2, mapped.b); assertEquals(3, mapped.c); }
@Test public void testMapTo_Object() throws Exception { final ClassTestMapToClass mapped = new ClassTestMapToClass(); assertSame(mapped, JBBPParser.prepare("byte a; byte b; byte c;").parse(new byte[] {1, 2, 3}).mapTo(mapped)); assertEquals(1, mapped.a); assertEquals(2, mapped.b); assertEquals(3, mapped.c); }