net.intelie.pipes.PropertyVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes;
public interface PropertyVisitor {
PropertyVisitor property(Property property);
PropertyVisitor anyProperty();
default PropertyVisitor unknown(Object obj) {
return anyProperty();
}
PropertyVisitor newScope();
PropertyVisitor newChildScope();
static PropertyVisitor visitChildScope(Scope parent, PropertyVisitor visitor, PropertySink expr) {
return expr.visit(new Scope(parent, visitor), visitor.newChildScope());
}
Empty EMPTY = new Empty();
class Empty implements PropertyVisitor {
@Override
public PropertyVisitor property(Property property) {
return EMPTY;
}
@Override
public PropertyVisitor anyProperty() {
return EMPTY;
}
@Override
public PropertyVisitor newScope() {
return EMPTY;
}
@Override
public PropertyVisitor newChildScope() {
return new ChildScope();
}
private class ChildScope extends Empty {
@Override
public PropertyVisitor unknown(Object obj) {
// If .unknown() is called within a child scope, it might be hiding an unvisited HatOperator,
// so call .unknown() also in the parent scope.
Empty.this.unknown(obj);
return super.unknown(obj);
}
}
}
}