JBBPFieldStruct extends JBBPAbstractField implements JBBPFieldFinder { public JBBPAbstractField[] getArray() { return this.fields.clone(); } 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 testConstructor_Fields() { final JBBPFieldStruct struct = new JBBPFieldStruct(null, new JBBPAbstractField[] {new JBBPFieldByte(null, (byte) 123), new JBBPFieldByte(null, (byte) -123)}); assertNull(struct.getNameInfo()); assertEquals(2, struct.getArray().length); }
@Test public void testConstructor_Name_Fields() { final JBBPFieldStruct struct = new JBBPFieldStruct(new JBBPNamedFieldInfo("test.struct", "struct", 999), new JBBPAbstractField[] {new JBBPFieldByte(null, (byte) 123), new JBBPFieldByte(null, (byte) -123)}); assertNotNull(struct.getNameInfo()); assertEquals("test.struct", struct.getNameInfo().getFieldPath()); assertEquals("struct", struct.getNameInfo().getFieldName()); assertEquals(999, struct.getNameInfo().getFieldOffsetInCompiledBlock()); assertEquals(2, struct.getArray().length); }
@Test public void testConstructor_Name_ListOfFields() { final JBBPFieldStruct struct = new JBBPFieldStruct(new JBBPNamedFieldInfo("test.struct", "struct", 999), JBBPUtils.fieldsAsList(new JBBPFieldByte(null, (byte) 123), new JBBPFieldByte(null, (byte) -123))); assertNotNull(struct.getNameInfo()); assertEquals("test.struct", struct.getNameInfo().getFieldPath()); assertEquals("struct", struct.getNameInfo().getFieldName()); assertEquals(999, struct.getNameInfo().getFieldOffsetInCompiledBlock()); assertEquals(2, struct.getArray().length); }