BTreeRecord { @SuppressWarnings("unchecked") public static <T extends BTreeRecord> T readRecord(int type, ByteBuffer buffer, DatasetInfo datasetInfo) { switch (type) { case 0: throw new HdfException("b-tree record type 0. Should only be used for testing"); case 1: return (T) new HugeFractalHeapObjectUnfilteredRecord(buffer); case 2: throw new UnsupportedHdfException("b-tree record type 2. Currently not supported"); case 3: throw new UnsupportedHdfException("b-tree record type 3. Currently not supported"); case 4: throw new UnsupportedHdfException("b-tree record type 4. Currently not supported"); case 5: return (T) new LinkNameForIndexedGroupRecord(buffer); case 6: throw new UnsupportedHdfException("b-tree record type 6. Currently not supported"); case 7: throw new UnsupportedHdfException("b-tree record type 7. Currently not supported"); case 8: return (T) new AttributeNameForIndexedAttributesRecord(buffer); case 9: throw new UnsupportedHdfException("b-tree record type 9. Currently not supported"); case 10: return (T) new NonFilteredDatasetChunks(buffer, datasetInfo); case 11: return (T) new FilteredDatasetChunks(buffer, datasetInfo); default: throw new HdfException("Unknown b-tree record type. Type = " + type); } }  @SuppressWarnings("unchecked") // Requires that the b-tree is of the correct type for the record static T readRecord(int type, ByteBuffer buffer, DatasetInfo datasetInfo);  }
@Test void testUnsupportedRecordTypesThrow() { assertThrows(HdfException.class, () -> BTreeRecord.readRecord(0, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(2, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(3, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(4, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(6, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(7, null, null)); assertThrows(UnsupportedHdfException.class, () -> BTreeRecord.readRecord(9, null, null)); }
@Test void testUnreconizedRecordTypeThrows() { assertThrows(HdfException.class, () -> BTreeRecord.readRecord(63, null, null)); }