@Test public void testPerfectMatch() { matcher = new NameMatcher( SchemaFixture.createSchema1("from"), SchemaFixture.createSchema1("to")); Object[] fields = SchemaFixture.createNotNullRecordForSchema1(); Object[] actual = matcher.getMatchingData(fields); assertArrayEquals(fields, actual); }
@Override public Object[] getMatchingData(Object[] fields) { if (getToSchema().isEmpty()) { return fields; } Object[] out = new Object[getToSchema().getColumnsCount()]; int i = 0; for (Column toCol : getToSchema().getColumnsList()) { Integer fromIndex = fromColNameIndexMap.get(toCol.getName()); if (fromIndex != null && fromIndex < fields.length) { out[i] = fields[fromIndex]; } else { tryFillNullInArrayForUnexpectedColumn(toCol, out, i); } i++; } return out; }
NameMatcher extends Matcher { @Override public Object[] getMatchingData(Object[] fields) { if (getToSchema().isEmpty()) { return fields; } Object[] out = new Object[getToSchema().getColumnsCount()]; int i = 0; for (Column toCol : getToSchema().getColumnsList()) { Integer fromIndex = fromColNameIndexMap.get(toCol.getName()); if (fromIndex != null && fromIndex < fields.length) { out[i] = fields[fromIndex]; } else { tryFillNullInArrayForUnexpectedColumn(toCol, out, i); } i++; } return out; } }
NameMatcher extends Matcher { @Override public Object[] getMatchingData(Object[] fields) { if (getToSchema().isEmpty()) { return fields; } Object[] out = new Object[getToSchema().getColumnsCount()]; int i = 0; for (Column toCol : getToSchema().getColumnsList()) { Integer fromIndex = fromColNameIndexMap.get(toCol.getName()); if (fromIndex != null && fromIndex < fields.length) { out[i] = fields[fromIndex]; } else { tryFillNullInArrayForUnexpectedColumn(toCol, out, i); } i++; } return out; } NameMatcher(Schema from, Schema to); }
NameMatcher extends Matcher { @Override public Object[] getMatchingData(Object[] fields) { if (getToSchema().isEmpty()) { return fields; } Object[] out = new Object[getToSchema().getColumnsCount()]; int i = 0; for (Column toCol : getToSchema().getColumnsList()) { Integer fromIndex = fromColNameIndexMap.get(toCol.getName()); if (fromIndex != null && fromIndex < fields.length) { out[i] = fields[fromIndex]; } else { tryFillNullInArrayForUnexpectedColumn(toCol, out, i); } i++; } return out; } NameMatcher(Schema from, Schema to); @Override Object[] getMatchingData(Object[] fields); }
NameMatcher extends Matcher { @Override public Object[] getMatchingData(Object[] fields) { if (getToSchema().isEmpty()) { return fields; } Object[] out = new Object[getToSchema().getColumnsCount()]; int i = 0; for (Column toCol : getToSchema().getColumnsList()) { Integer fromIndex = fromColNameIndexMap.get(toCol.getName()); if (fromIndex != null && fromIndex < fields.length) { out[i] = fields[fromIndex]; } else { tryFillNullInArrayForUnexpectedColumn(toCol, out, i); } i++; } return out; } NameMatcher(Schema from, Schema to); @Override Object[] getMatchingData(Object[] fields);  }