
org.bitbucket.gkutiel.at.Context Maven / Gradle / Ivy
package org.bitbucket.gkutiel.at;
import java.util.Iterator;
public abstract class Context implements Iterable {
final Context parent;
public static final Context nullContext = new Context(null) {
@Override public Context get(final String name) {
return this;
}
};
public Context(final Context parent) {
this.parent = parent;
}
public void add(final Context ctx) {
if (parent == null) throw new RuntimeException("can't add");
parent.add(ctx);
}
public Context get(final String name) {
if (parent == null) return nullContext;
return parent.get(name);
}
@Override public Iterator iterator() {
throw new RuntimeException("can't iterate over me");
}
public void set(final String name, final Context ctx) {
if (parent == null) throw new RuntimeException("can't set");
parent.set(name, ctx);
}
@SuppressWarnings("static-method") public String val() {
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy