blob: a275e3697a25a8287fde822950d46bf2db1b20ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
import com.yahoo.component.ComponentId;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.query.profile.types.QueryProfileType;
/**
* A regular query profile which knows it is storing overrides (not configured profiles)
* and that implements override legality checking.
*
* @author bratseth
*/
public class OverridableQueryProfile extends QueryProfile {
private static final String simpleClassName = OverridableQueryProfile.class.getSimpleName();
/** Creates an unbacked overridable query profile */
protected OverridableQueryProfile() {
super(ComponentId.createAnonymousComponentId(simpleClassName));
}
@Override
protected Object checkAndConvertAssignment(String localName, Object inputValue, QueryProfileRegistry registry) {
Object value=super.checkAndConvertAssignment(localName, inputValue, registry);
if (value!=null && value.getClass() == QueryProfile.class) { // We are assigning a query profile - make it overridable
return new BackedOverridableQueryProfile((QueryProfile)value);
}
return value;
}
@Override
protected QueryProfile createSubProfile(String name,DimensionBinding binding) {
return new OverridableQueryProfile(); // Nothing is set in this branch, so nothing to override, but need override checking
}
/** Returns a clone of this which can be independently overridden */
@Override
public OverridableQueryProfile clone() {
if (isFrozen()) return this;
OverridableQueryProfile clone=(OverridableQueryProfile)super.clone();
clone.initId(ComponentId.createAnonymousComponentId(simpleClassName));
return clone;
}
@Override
public String toString() {
return "an overridable query profile with no backing";
}
}
|