@Test public void testDefaultValueWithAliasesDefined() { final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("foo", RecordFieldType.STRING.getDataType(), "hello", set("bar", "baz"))); final RecordSchema schema = new SimpleRecordSchema(fields); final Map<String, Object> values = new HashMap<>(); final Record record = new MapRecord(schema, values); assertEquals("hello", record.getValue("foo")); assertEquals("hello", record.getValue("bar")); assertEquals("hello", record.getValue("baz")); }
@Override public Object getValue(final String fieldName) { final Optional<RecordField> fieldOption = schema.getField(fieldName); if (fieldOption.isPresent()) { return getValue(fieldOption.get()); } if (dropUnknownFields) { return null; } return this.values.get(fieldName); }
MapRecord implements Record { @Override public Object getValue(final String fieldName) { final Optional<RecordField> fieldOption = schema.getField(fieldName); if (fieldOption.isPresent()) { return getValue(fieldOption.get()); } if (dropUnknownFields) { return null; } return this.values.get(fieldName); } }
MapRecord implements Record { @Override public Object getValue(final String fieldName) { final Optional<RecordField> fieldOption = schema.getField(fieldName); if (fieldOption.isPresent()) { return getValue(fieldOption.get()); } if (dropUnknownFields) { return null; } return this.values.get(fieldName); } MapRecord(final RecordSchema schema, final Map<String, Object> values);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final boolean checkTypes, final boolean dropUnknownFields);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm, final boolean checkTypes, final boolean dropUnknownFields); }
MapRecord implements Record { @Override public Object getValue(final String fieldName) { final Optional<RecordField> fieldOption = schema.getField(fieldName); if (fieldOption.isPresent()) { return getValue(fieldOption.get()); } if (dropUnknownFields) { return null; } return this.values.get(fieldName); } MapRecord(final RecordSchema schema, final Map<String, Object> values);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final boolean checkTypes, final boolean dropUnknownFields);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm, final boolean checkTypes, final boolean dropUnknownFields); @Override boolean isDropUnknownFields(); @Override boolean isTypeChecked(); @Override RecordSchema getSchema(); @Override Object[] getValues(); @Override Object getValue(final String fieldName); @Override Object getValue(final RecordField field); @Override String getAsString(final String fieldName); @Override String getAsString(final String fieldName, final String format); @Override String getAsString(final RecordField field, final String format); @Override Long getAsLong(final String fieldName); @Override Integer getAsInt(final String fieldName); @Override Double getAsDouble(final String fieldName); @Override Float getAsFloat(final String fieldName); @Override Record getAsRecord(String fieldName, final RecordSchema schema); @Override Boolean getAsBoolean(final String fieldName); @Override Date getAsDate(final String fieldName, final String format); @Override Object[] getAsArray(final String fieldName); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override Optional<SerializedForm> getSerializedForm(); @Override void setValue(final String fieldName, final Object value); @Override void setArrayValue(final String fieldName, final int arrayIndex, final Object value); @Override @SuppressWarnings("unchecked") void setMapValue(final String fieldName, final String mapKey, final Object value); @Override void incorporateSchema(RecordSchema other); @Override Set<String> getRawFieldNames(); }
MapRecord implements Record { @Override public Object getValue(final String fieldName) { final Optional<RecordField> fieldOption = schema.getField(fieldName); if (fieldOption.isPresent()) { return getValue(fieldOption.get()); } if (dropUnknownFields) { return null; } return this.values.get(fieldName); } MapRecord(final RecordSchema schema, final Map<String, Object> values);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final boolean checkTypes, final boolean dropUnknownFields);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm);  MapRecord(final RecordSchema schema, final Map<String, Object> values, final SerializedForm serializedForm, final boolean checkTypes, final boolean dropUnknownFields); @Override boolean isDropUnknownFields(); @Override boolean isTypeChecked(); @Override RecordSchema getSchema(); @Override Object[] getValues(); @Override Object getValue(final String fieldName); @Override Object getValue(final RecordField field); @Override String getAsString(final String fieldName); @Override String getAsString(final String fieldName, final String format); @Override String getAsString(final RecordField field, final String format); @Override Long getAsLong(final String fieldName); @Override Integer getAsInt(final String fieldName); @Override Double getAsDouble(final String fieldName); @Override Float getAsFloat(final String fieldName); @Override Record getAsRecord(String fieldName, final RecordSchema schema); @Override Boolean getAsBoolean(final String fieldName); @Override Date getAsDate(final String fieldName, final String format); @Override Object[] getAsArray(final String fieldName); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override Optional<SerializedForm> getSerializedForm(); @Override void setValue(final String fieldName, final Object value); @Override void setArrayValue(final String fieldName, final int arrayIndex, final Object value); @Override @SuppressWarnings("unchecked") void setMapValue(final String fieldName, final String mapKey, final Object value); @Override void incorporateSchema(RecordSchema other); @Override Set<String> getRawFieldNames();  }