public Map<String, String> getUsedCustomLogicalTypeFactories(Schema schema) {
    final Set<String> logicalTypeNames = getUsedLogicalTypes(schema).stream().map(LogicalType::getName)
        .collect(Collectors.toSet());

    return LogicalTypes.getCustomRegisteredTypes().entrySet().stream()
        .filter(entry -> logicalTypeNames.contains(entry.getKey()))
        .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getClass().getCanonicalName()));
  }
@Test
  void getUsedCustomLogicalTypeFactories() throws Exception {
    LogicalTypes.register("string-custom", new StringCustomLogicalTypeFactory());

    SpecificCompiler compiler = createCompiler();
    compiler.setEnableDecimalLogicalType(true);

    final Schema schema = new Schema.Parser().parse("{\"type\":\"record\"," + "\"name\":\"NestedLogicalTypesRecord\","
        + "\"namespace\":\"org.apache.avro.codegentest.testdata\","
        + "\"doc\":\"Test nested types with logical types in generated Java classes\"," + "\"fields\":["
        + "{\"name\":\"nestedRecord\",\"type\":" + "{\"type\":\"record\",\"name\":\"NestedRecord\",\"fields\":"
        + "[{\"name\":\"nullableDateField\"," + "\"type\":[\"null\",{\"type\":\"int\",\"logicalType\":\"date\"}]}]}},"
        + "{\"name\":\"myLogical\",\"type\":{\"type\":\"string\",\"logicalType\":\"string-custom\"}}]}");

    final Map<String, String> usedCustomLogicalTypeFactories = compiler.getUsedCustomLogicalTypeFactories(schema);
    assertEquals(1, usedCustomLogicalTypeFactories.size());
    final Map.Entry<String, String> entry = usedCustomLogicalTypeFactories.entrySet().iterator().next();
    assertEquals("string-custom", entry.getKey());
    assertEquals("org.apache.avro.compiler.specific.TestSpecificCompiler.StringCustomLogicalTypeFactory",
        entry.getValue());
  }