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

net.intelie.pipes.PropertyVisitor Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
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);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy