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

net.nemerosa.ontrack.ui.resource.LinkContainer Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.ui.resource;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import lombok.Data;

import java.net.URI;
import java.util.LinkedHashMap;
import java.util.Map;

@Data
public abstract class LinkContainer> {

    private final URI _self;
    private final Map links;

    protected LinkContainer(URI uri) {
        this(uri, new LinkedHashMap<>());
    }

    protected LinkContainer(URI uri, Map links) {
        this._self = uri;
        this.links = links;
    }

    public L with(String name, URI uri, boolean authorized) {
        if (authorized) {
            return with(name, uri);
        } else {
            //noinspection unchecked
            return (L) this;
        }
    }

    private L with(Link link) {
        return with(link.getName(), link.getHref());
    }

    public L with(String name, URI uri) {
        links.put(name, uri);
        //noinspection unchecked
        return (L) this;
    }

    @JsonAnyGetter
    public Map getLinks() {
        return links;
    }

    public L withLinks(Map links) {
        this.links.putAll(links);
        //noinspection unchecked
        return (L) this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy