// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile; import java.util.List; /** * Visitor which stores the first non-query-profile value encountered, * or the first query profile encountered at a stop where we do not have any name components left which can be used to * visit further subprofiles. Hence this may be used both to get the highest prioritized primitive * value, or query profile, whichever is encountered first which matches the name. *

* * @author bratseth */ final class SingleValueQueryProfileVisitor extends QueryProfileVisitor { /** The value found, or null if none */ private Object value=null; private final List name; private int nameIndex=-1; private final boolean allowQueryProfileResult; private boolean enteringContent=true; public SingleValueQueryProfileVisitor(List name,boolean allowQueryProfileResult) { this.name=name; this.allowQueryProfileResult=allowQueryProfileResult; } public @Override String getLocalKey() { return name.get(nameIndex); } public @Override boolean enter(String name) { if (nameIndex+1