JBBPFieldStruct extends JBBPAbstractField implements JBBPFieldFinder { @Override public boolean nameExists(final String fieldName) { final String normalizedName = JBBPUtils.normalizeFieldNameOrPath(fieldName); boolean result = false; for (final JBBPAbstractField f : this.fields) { if (normalizedName.equals(f.getFieldName())) { result = true; break; } } return result; } 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 testNameExists() { final JBBPFieldByte field1 = new JBBPFieldByte(new JBBPNamedFieldInfo("struct.field1", "field1", 1024), (byte) 23); final JBBPFieldInt field2 = new JBBPFieldInt(new JBBPNamedFieldInfo("struct.field2", "field2", 1960), 23432); final JBBPFieldByte field3 = new JBBPFieldByte(new JBBPNamedFieldInfo("struct.field3", "field3", 2048), (byte) 78); final JBBPFieldStruct struct = new JBBPFieldStruct(new JBBPNamedFieldInfo("test.struct", "struct", 999), new JBBPAbstractField[] {field1, field2, field3}); assertFalse(struct.nameExists("struct.field1")); assertTrue(struct.nameExists("field1")); assertFalse(struct.nameExists("struct.field4")); assertTrue(struct.nameExists("field3")); }