@Test public void mangled() { DataModelDescriptor descriptor = FieldPropertyDescriptor.extract(MockSimple.class); MockSimple obj = (MockSimple) descriptor.createDataModelObject(); obj.number.modify(12345); obj.string.modify("Hello, world!"); List<PropertyDescriptor> properties = new ArrayList<>(); for (PropertyDescriptor property : descriptor.getPropertyDescriptors()) { properties.add(new PropertyDescriptor(String.format("_col%d", properties.size()), property) { @Override public ValueOption<?> extract(Object dataModel) { return property.extract(dataModel); } }); } DataModelDescriptor mangled = new DataModelDescriptor(descriptor.getDataModelClass(), properties); DataModelMapping config = new DataModelMapping(); config.setFieldMappingStrategy(FieldMappingStrategy.NAME); config.setOnMissingSource(ExceptionHandlingStrategy.FAIL); config.setOnMissingTarget(ExceptionHandlingStrategy.IGNORE); config.setOnIncompatibleType(ExceptionHandlingStrategy.IGNORE); try { DataModelDriver driver = new DataModelDriver(descriptor, new DataModelInspector(mangled), config); MockSimple copy = new MockSimple(); driver.set(copy, obj); throw new AssertionError(); } catch (IllegalArgumentException e) { } config.setFieldMappingStrategy(FieldMappingStrategy.POSITION); DataModelDriver driver = new DataModelDriver(descriptor, new DataModelInspector(mangled), config); MockSimple copy = new MockSimple(); driver.set(copy, obj); assertThat(copy.number, equalTo(obj.number)); assertThat(copy.string, equalTo(obj.string)); }
public void set(Object dataModel, Object source) { StructObjectInspector inspector = this.sourceInspector; StructField[] sources = this.sourceFields; PropertyDescriptor[] targets = this.targetProperties; ValueDriver[] drivers = propertyDrivers; for (int i = 0; i < sources.length; i++) { Object value = inspector.getStructFieldData(source, sources[i]); ValueOption<?> option = targets[i].extract(dataModel); drivers[i].set(option, value); } }
DataModelDriver { public void set(Object dataModel, Object source) { StructObjectInspector inspector = this.sourceInspector; StructField[] sources = this.sourceFields; PropertyDescriptor[] targets = this.targetProperties; ValueDriver[] drivers = propertyDrivers; for (int i = 0; i < sources.length; i++) { Object value = inspector.getStructFieldData(source, sources[i]); ValueOption<?> option = targets[i].extract(dataModel); drivers[i].set(option, value); } } }
DataModelDriver { public void set(Object dataModel, Object source) { StructObjectInspector inspector = this.sourceInspector; StructField[] sources = this.sourceFields; PropertyDescriptor[] targets = this.targetProperties; ValueDriver[] drivers = propertyDrivers; for (int i = 0; i < sources.length; i++) { Object value = inspector.getStructFieldData(source, sources[i]); ValueOption<?> option = targets[i].extract(dataModel); drivers[i].set(option, value); } } DataModelDriver(DataModelDescriptor descriptor, StructObjectInspector sourceInspector);  DataModelDriver(
            DataModelDescriptor descriptor, StructObjectInspector sourceInspector, DataModelMapping configuration); }
DataModelDriver { public void set(Object dataModel, Object source) { StructObjectInspector inspector = this.sourceInspector; StructField[] sources = this.sourceFields; PropertyDescriptor[] targets = this.targetProperties; ValueDriver[] drivers = propertyDrivers; for (int i = 0; i < sources.length; i++) { Object value = inspector.getStructFieldData(source, sources[i]); ValueOption<?> option = targets[i].extract(dataModel); drivers[i].set(option, value); } } DataModelDriver(DataModelDescriptor descriptor, StructObjectInspector sourceInspector);  DataModelDriver(
            DataModelDescriptor descriptor, StructObjectInspector sourceInspector, DataModelMapping configuration); StructObjectInspector getSourceInspector(); List<StructField> getSourceFields(); void set(Object dataModel, Object source); }
DataModelDriver { public void set(Object dataModel, Object source) { StructObjectInspector inspector = this.sourceInspector; StructField[] sources = this.sourceFields; PropertyDescriptor[] targets = this.targetProperties; ValueDriver[] drivers = propertyDrivers; for (int i = 0; i < sources.length; i++) { Object value = inspector.getStructFieldData(source, sources[i]); ValueOption<?> option = targets[i].extract(dataModel); drivers[i].set(option, value); } } DataModelDriver(DataModelDescriptor descriptor, StructObjectInspector sourceInspector);  DataModelDriver(
            DataModelDescriptor descriptor, StructObjectInspector sourceInspector, DataModelMapping configuration); StructObjectInspector getSourceInspector(); List<StructField> getSourceFields(); void set(Object dataModel, Object source);  }