@Test public void nulls() { DataModelDescriptor descriptor = FieldPropertyDescriptor.extract(MockTypes.class); MockTypes obj = (MockTypes) descriptor.createDataModelObject(); DataModelInspector inspector = new DataModelInspector(descriptor); assertThat(inspector.getTypeName(), is(MockTypes.class.getName())); assertThat(inspector.getAllStructFieldRefs(), hasSize(11)); assertThat(inspector.getStructFieldsDataAsList(obj), is(Arrays.asList(new Object[11]))); assertThat(getJavaField(inspector, obj, "booleanOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "byteOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "shortOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "intOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "longOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "floatOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "doubleOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "decimalOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "stringOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "dateOption"), is(nullValue())); assertThat(getJavaField(inspector, obj, "dateTimeOption"), is(nullValue())); DataModelDriver driver = new DataModelDriver(descriptor, inspector); MockTypes copy = new MockTypes(); copy.booleanOption.modify(true); copy.byteOption.modify((byte) 1); copy.shortOption.modify((short) 2); copy.intOption.modify(3); copy.longOption.modify(4L); copy.floatOption.modify(5f); copy.doubleOption.modify(6d); copy.dateOption.modify(new Date(2014, 6, 1)); copy.dateTimeOption.modify(new DateTime(2014, 6, 1, 2, 3, 4)); copy.stringOption.modify("Hello, world!"); copy.decimalOption.modify(new BigDecimal("7.8")); driver.set(copy, obj); assertThat(copy.booleanOption.isNull(), is(true)); assertThat(copy.byteOption.isNull(), is(true)); assertThat(copy.shortOption.isNull(), is(true)); assertThat(copy.intOption.isNull(), is(true)); assertThat(copy.longOption.isNull(), is(true)); assertThat(copy.floatOption.isNull(), is(true)); assertThat(copy.doubleOption.isNull(), is(true)); assertThat(copy.dateOption.isNull(), is(true)); assertThat(copy.dateTimeOption.isNull(), is(true)); assertThat(copy.stringOption.isNull(), is(true)); assertThat(copy.decimalOption.isNull(), is(true)); }
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);  }