All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vladsch.flexmark.ast.util.LinkResolverAdapter Maven / Gradle / Ivy

Go to download

Core of flexmark-java (implementation of CommonMark for parsing markdown and rendering to HTML)

The newest version!
package com.vladsch.flexmark.ast.util;

import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext;
import com.vladsch.flexmark.html.renderer.ResolvedLink;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.visitor.AstActionHandler;

import java.util.Collection;

@SuppressWarnings("rawtypes")
public class LinkResolverAdapter extends AstActionHandler, LinkResolvingHandler> implements LinkResolvingHandler.LinkResolvingVisitor {
    protected static final LinkResolvingHandler[] EMPTY_HANDLERS = new LinkResolvingHandler[0];

    public LinkResolverAdapter(LinkResolvingHandler... handlers) {
        super(Node.AST_ADAPTER);
        super.addActionHandlers(handlers);
    }

    public LinkResolverAdapter(LinkResolvingHandler[]... handlers) {
        super(Node.AST_ADAPTER);
        //noinspection unchecked
        super.addActionHandlers(handlers);
    }

    public LinkResolverAdapter(Collection handlers) {
        super(Node.AST_ADAPTER);
        addHandlers(handlers);
    }

    // add handler variations
    public LinkResolverAdapter addHandlers(Collection handlers) {
        return super.addActionHandlers(handlers.toArray(EMPTY_HANDLERS));
    }

    public LinkResolverAdapter addHandlers(LinkResolvingHandler[] handlers) {
        return super.addActionHandlers(handlers);
    }

    public LinkResolverAdapter addHandlers(LinkResolvingHandler[]... handlers) {
        //noinspection unchecked
        return super.addActionHandlers(handlers);
    }

    public LinkResolverAdapter addHandler(LinkResolvingHandler handler) {
        //noinspection unchecked
        return super.addActionHandler(handler);
    }

    @Override
    public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) {
        return processNodeOnly(node, link, (n, handler) -> handler.resolveLink(n, context, link));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy