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

io.quarkus.resteasy.reactive.links.runtime.LinksContainer Maven / Gradle / Ivy

Go to download

Web Links support for Quarkus REST. Inject web links into response HTTP headers by annotating your endpoint resources.

The newest version!
package io.quarkus.resteasy.reactive.links.runtime;

import java.util.Collections;
import java.util.List;

import jakarta.ws.rs.core.MultivaluedMap;

import org.jboss.resteasy.reactive.common.util.MultivaluedTreeMap;

import io.quarkus.runtime.annotations.RecordableConstructor;

/**
 * A container holding links mapped by an entity which they represent.
 */
public final class LinksContainer {

    /**
     * Links mapped by their entity type.
     * In order to be recorded this field name has to match the constructor parameter name and have a getter.
     */
    private final MultivaluedMap linksMap;

    public LinksContainer() {
        linksMap = new MultivaluedTreeMap<>();
    }

    @RecordableConstructor
    public LinksContainer(MultivaluedMap linksMap) {
        this.linksMap = linksMap;
    }

    public List getForClass(Class c) {
        return linksMap.getOrDefault(c.getName(), Collections.emptyList());
    }

    public void put(LinkInfo linkInfo) {
        linksMap.add(linkInfo.getEntityType(), linkInfo);
    }

    public MultivaluedMap getLinksMap() {
        return MultivaluedTreeMap.clone(linksMap);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy