OracleIndexMetadataParser implements IndexMetadataParser { @Override public List<RDBIndexMetadata> parseTableIndex(String tableName) { String schemaName = schema.getName().toUpperCase(); String tableUpperName = tableName.toUpperCase(); return schema.<SyncSqlExecutor>findFeature(SyncSqlExecutor.ID) .map(sqlExecutor -> sqlExecutor.select(prepare(sql, schemaName, tableUpperName), new OracleIndexWrapper( sqlExecutor .select(prepare(virtualColumnSql, schemaName, tableUpperName), lowerCase(mapStream())) .map(CastUtil::<Map<String, String>>cast) .collect(Collectors.toMap(map -> map.get("column_name"), map -> map.get("data_default"))) , sqlExecutor .select(prepare(primaryKeyIndexSql, schemaName, tableUpperName), stream(column("index_name", String::valueOf))) .collect(Collectors.toSet()) ))) .orElseGet(() -> { log.warn("unsupported SyncSqlExecutor"); return Collections.emptyList(); }); }  @Override List<RDBIndexMetadata> parseTableIndex(String tableName); @Override Optional<RDBIndexMetadata> parseByName(String name); @Override List<RDBIndexMetadata> parseAll(); @Override Flux<RDBIndexMetadata> parseAllReactive(); @Override Mono<RDBIndexMetadata> parseByNameReactive(String name); @Override Flux<RDBIndexMetadata> parseTableIndexReactive(String tableName);  }
@Test public void test() { SyncSqlExecutor sqlExecutor = new TestSyncSqlExecutor(new OracleConnectionProvider()); try { OracleSchemaMetadata schema= new OracleSchemaMetadata("SYSTEM"); schema.setDatabase(new RDBDatabaseMetadata(Dialect.ORACLE)); OracleIndexMetadataParser parser =OracleIndexMetadataParser.of(schema); schema.addFeature(sqlExecutor); sqlExecutor.execute(SqlRequests.of( "create table test_index_parser(" + "id varchar2(32) primary key," + "name varchar2(32) not null," + "age int," + "addr varchar2(128))")); sqlExecutor.execute(SqlRequests.of("create index test_index on test_index_parser (age)")); sqlExecutor.execute(SqlRequests.of("create unique index test_index_2 on test_index_parser (name)")); sqlExecutor.execute(SqlRequests.of("create index test_index_3 on test_index_parser (name,addr desc)")); List<RDBIndexMetadata> list = parser.parseTableIndex("test_index_parser"); Assert.assertEquals(list.size(),4); Assert.assertTrue(list.stream().anyMatch(RDBIndexMetadata::isPrimaryKey)); } finally { try { sqlExecutor.execute(SqlRequests.of("drop table test_index_parser")); } catch (Exception e) { } } }