@Test public void types() { DataModelDescriptor descriptor = FieldPropertyDescriptor.extract(MockTypes.class); MockTypes obj = (MockTypes) descriptor.createDataModelObject(); obj.booleanOption.modify(true); obj.byteOption.modify((byte) 1); obj.shortOption.modify((short) 2); obj.intOption.modify(3); obj.longOption.modify(4L); obj.floatOption.modify(5f); obj.doubleOption.modify(6d); obj.dateOption.modify(new Date(2014, 6, 1)); obj.dateTimeOption.modify(new DateTime(2014, 6, 1, 2, 3, 4)); obj.stringOption.modify("Hello, world!"); obj.decimalOption.modify(new BigDecimal("7.8")); 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[] { obj.booleanOption, obj.byteOption, obj.shortOption, obj.intOption, obj.longOption, obj.floatOption, obj.doubleOption, obj.dateOption, obj.dateTimeOption, obj.stringOption, obj.decimalOption, }))); assertThat(getJavaField(inspector, obj, "booleanOption"), equalTo((Object) obj.booleanOption.get())); assertThat(getJavaField(inspector, obj, "byteOption"), equalTo((Object) obj.byteOption.get())); assertThat(getJavaField(inspector, obj, "shortOption"), equalTo((Object) obj.shortOption.get())); assertThat(getJavaField(inspector, obj, "intOption"), equalTo((Object) obj.intOption.get())); assertThat(getJavaField(inspector, obj, "longOption"), equalTo((Object) obj.longOption.get())); assertThat(getJavaField(inspector, obj, "floatOption"), equalTo((Object) obj.floatOption.get())); assertThat(getJavaField(inspector, obj, "doubleOption"), equalTo((Object) obj.doubleOption.get())); Calendar calendar = Calendar.getInstance(); DateUtil.setDayToCalendar(obj.dateOption.get().getElapsedDays(), calendar); assertThat(getJavaField(inspector, obj, "dateOption"), equalTo((Object) new java.sql.Date(calendar.getTimeInMillis()))); DateUtil.setSecondToCalendar(obj.dateTimeOption.get().getElapsedSeconds(), calendar); assertThat(getJavaField(inspector, obj, "dateTimeOption"), equalTo((Object) new java.sql.Timestamp(calendar.getTimeInMillis()))); assertThat(getJavaField(inspector, obj, "stringOption"), equalTo((Object) obj.stringOption.getAsString())); assertThat(((HiveDecimal) getJavaField(inspector, obj, "decimalOption")), equalTo(HiveDecimal.create(obj.decimalOption.get()))); DataModelDriver driver = new DataModelDriver(descriptor, inspector); MockTypes copy = new MockTypes(); driver.set(copy, obj); assertThat(copy.booleanOption, equalTo(obj.booleanOption)); assertThat(copy.byteOption, equalTo(obj.byteOption)); assertThat(copy.shortOption, equalTo(obj.shortOption)); assertThat(copy.intOption, equalTo(obj.intOption)); assertThat(copy.longOption, equalTo(obj.longOption)); assertThat(copy.floatOption, equalTo(obj.floatOption)); assertThat(copy.doubleOption, equalTo(obj.doubleOption)); assertThat(copy.dateOption, equalTo(obj.dateOption)); assertThat(copy.dateTimeOption, equalTo(obj.dateTimeOption)); assertThat(copy.stringOption, equalTo(obj.stringOption)); assertThat(copy.decimalOption, equalTo(obj.decimalOption)); }
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);  }