class DefaultTypeRegistry extends AbstractEventSpy implements TypeRegistry {
    private final Map<String, Type> types;

    private final LanguageRegistry languageRegistry;

    private final ConcurrentHashMap<String, Type> usedTypes;

    private final LegacyArtifactHandlerManager manager;

    @Inject
    public DefaultTypeRegistry(
            List<TypeProvider> providers, LanguageRegistry languageRegistry, LegacyArtifactHandlerManager manager) {
        this.types = nonNull(providers, "providers").stream()
                .flatMap(p -> p.provides().stream())
                .collect(Collectors.toMap(Type::id, identity()));
        this.languageRegistry = nonNull(languageRegistry, "languageRegistry");
        this.usedTypes = new ConcurrentHashMap<>();
        this.manager = nonNull(manager, "artifactHandlerManager");
    }

    @Override
    public void onEvent(Object event) {
        if (event instanceof ExecutionEvent) {
            ExecutionEvent executionEvent = (ExecutionEvent) event;
            if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
                usedTypes.clear();
            }
        }
    }

    @Override
    public Optional<Type> lookup(String id) {
        return Optional.of(require(id));
    }

    @Override
    @Nonnull
    public Type require(String id) {<FILL_FUNCTION_BODY>}
}

        nonNull(id, "id");
        return usedTypes.computeIfAbsent(id, i -> {
            Type type = types.get(id);
            if (type == null) {
                // Copy data as the ArtifactHandler is not immutable, but Type should be.
                ArtifactHandler handler = manager.getArtifactHandler(id);
                type = new DefaultType(
                        id,
                        languageRegistry.require(handler.getLanguage()),
                        handler.getExtension(),
                        handler.getClassifier(),
                        handler.isIncludesDependencies(),
                        JavaPathType.CLASSES,
                        JavaPathType.MODULES);
            }
            return type;
        });
    
<methods>public non-sealed void <init>() ,public void close() throws java.lang.Exception,public void init(org.apache.maven.eventspy.EventSpy.Context) throws java.lang.Exception,public void onEvent(java.lang.Object) throws java.lang.Exception<variables>