net.nemerosa.ontrack.ui.resource.LinkContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-ui-support Show documentation
Show all versions of ontrack-ui-support Show documentation
Ontrack module: ontrack-ui-support
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