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

net.n2oapp.framework.config.metadata.compile.ParentRouteScope Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.config.metadata.compile;

import lombok.Getter;
import net.n2oapp.framework.api.metadata.meta.ModelLink;
import net.n2oapp.framework.config.register.route.RouteUtil;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Текущий маршрут метаданной при её сборке
 */
@Getter
public class ParentRouteScope {
    private String url;
    private Map pathMapping = new HashMap<>();
    private Map queryMapping = new LinkedHashMap<>();

    public ParentRouteScope(String url) {
        this.url = url;
    }

    public ParentRouteScope(String url, Map pathMapping, Map queryMapping) {
        this(url);
        if (pathMapping != null) {
            this.pathMapping.putAll(pathMapping);
        }
        if (queryMapping != null) {
            this.queryMapping.putAll(queryMapping);
        }
    }

    public ParentRouteScope(String route, ParentRouteScope parent) {
        this(RouteUtil.normalize(parent.getUrl() + route), parent.getPathMapping(), parent.getQueryMapping());
    }

    public ParentRouteScope(String route,
                            Map additionalPathMapping, Map additionalQueryMapping,
                            ParentRouteScope parent) {
        this(route, parent);
        if (additionalPathMapping != null)
            pathMapping.putAll(additionalPathMapping);
        if (additionalQueryMapping != null)
            queryMapping.putAll(additionalQueryMapping);
    }

    @Override
    public String toString() {
        return queryMapping != null ? RouteUtil.addQueryParams(url, queryMapping) : url;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy