CollapserUtils { public static boolean haveEqualSchema(Collection<IndexedRecord> records) { if (records == null || records.isEmpty()) { return true; } Schema schema = records.iterator().next().getSchema(); for (IndexedRecord record : records) { if (!schema.equals(record.getSchema())) { return false; } } return true; } private  CollapserUtils(); static boolean haveEqualSchema(Collection<IndexedRecord> records); static boolean isEnvelopeSchema(Schema schema); static String getOriginValue(IndexedRecord record); static IndexedRecord getDataRecord(IndexedRecord record); @SuppressWarnings("unchecked") static T getNestedFieldValue(IndexedRecord record, String fieldName); static int getNumberOfFilledFields(IndexedRecord record, List<String> fields); static void sortByFilledDataFields(List<T> records, final List<String> fields); static T merge(T base, T update);  }
@Test public void testHaveEqualSchema() { assertTrue(CollapserUtils.haveEqualSchema(null)); assertTrue(CollapserUtils.haveEqualSchema(new ArrayList<IndexedRecord>())); assertTrue(CollapserUtils.haveEqualSchema( Lists.newArrayList((IndexedRecord)SampleData.envMetadataRecord11, SampleData.envMetadataRecord12))); assertFalse(CollapserUtils.haveEqualSchema( Lists.newArrayList((IndexedRecord)SampleData.envMetadataRecord11, SampleData.envMetadataRecord12, SampleData.envTextRecord))); }