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

io.yawp.repository.Namespace Maven / Gradle / Ivy

There is a newer version: 2.08alpha
Show newest version
package io.yawp.repository;

import io.yawp.driver.api.NamespaceDriver;
import io.yawp.repository.annotations.Global;

public class Namespace {

    public static String GLOBAL = "";

    private NamespaceDriver driver;

    private String ns;

    private String previousNs;

    public Namespace(NamespaceDriver driver) {
        this.driver = driver;
    }

    public Namespace(String ns, NamespaceDriver driver) {
        this.ns = ns;
        this.driver = driver;
    }

    public void set(Class clazz) {
        previousNs = driver.get();
        configureNs(clazz.isAnnotationPresent(Global.class) ? GLOBAL : ns);
    }

    private void configureNs(String ns) {
        if (ns != null) {
            driver.set(ns);
        }
    }

    public void reset() {
        driver.set(previousNs);
    }

    public void setNs(String ns) {
        this.ns = ns;
    }

    public String getNs() {
        return ns;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy