Class QueryProfileType
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.component.provider.FreezableSimpleComponent
-
- com.yahoo.search.query.profile.types.QueryProfileType
-
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.provider.Freezable
,java.lang.Comparable<com.yahoo.component.Component>
public class QueryProfileType extends com.yahoo.component.provider.FreezableSimpleComponent
Defines a kind of query profiles- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description QueryProfileType(com.yahoo.component.ComponentId id)
QueryProfileType(java.lang.String idString)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addField(FieldDescription fieldDescription)
Adds a field to this, without associating with a type registry; field descriptions with compound is not be supported.void
addField(FieldDescription fieldDescription, QueryProfileTypeRegistry registry)
Adds a field to thisjava.util.Map<java.lang.String,java.lang.String>
aliases()
Returns the alias to field mapping of this type as a read-only map.java.util.Map<java.lang.String,FieldDescription>
declaredFields()
Returns the fields declared in this (i.e not including those inherited) as an immutable map.boolean
equals(java.lang.Object o)
Two types are equal if they have the same idjava.util.Map<java.lang.String,FieldDescription>
fields()
Returns all the fields of this profile type and all types it inherits as a read-only mapvoid
freeze()
com.yahoo.processing.request.CompoundName
getComponentIdAsCompoundName()
boolean
getDeclaredMatchAsPath()
Returns true if this is declared as match as path.FieldDescription
getField(java.lang.String name)
Returns the description of the field with the given name in this type or an inherited type (depth first left to right search).FieldType
getFieldType(com.yahoo.processing.request.CompoundName name)
Returns the field type of the given name under this, of null if noneboolean
getMatchAsPath()
Returns whether instances of this should be matched as path names.QueryProfileType
getType(java.lang.String localName)
Returns the type of the given query profile type declared as a field in thisjava.lang.Class<?>
getValueClass(java.lang.String name)
Returns the permissible class for the value of the given name in this typeint
hashCode()
java.util.List<QueryProfileType>
inherited()
Returns the query profile types inherited from this (never null).boolean
isBuiltin()
Returns whether this type is built into the systemboolean
isDeclaredStrict()
Returns true if this is declared strict.boolean
isOverridable(java.lang.String fieldName)
Returns whether the given field name is overridable in this type.boolean
isStrict()
Returns whether field not declared in this type is permissible in instances.FieldDescription
removeField(java.lang.String fieldName)
Removes a field from this (not from any inherited profile)void
setBuiltin(boolean builtin)
Mark this type as built into the system.void
setMatchAsPath(boolean matchAsPath)
Returns whether instances of this should be matched as path names.void
setStrict(boolean strict)
Set whether nondeclared fields are permissible.java.lang.String
toString()
java.lang.String
unalias(java.lang.String aliasOrField)
Returns the field name of an alias or field nameQueryProfileType
unfrozen()
Return this is it is not frozen, returns a modifiable deeply unfrozen copy otherwise-
Methods inherited from class com.yahoo.component.provider.FreezableSimpleComponent
clone, ensureNotFrozen, isFrozen
-
-
-
-
Method Detail
-
unfrozen
public QueryProfileType unfrozen()
Return this is it is not frozen, returns a modifiable deeply unfrozen copy otherwise
-
getComponentIdAsCompoundName
public com.yahoo.processing.request.CompoundName getComponentIdAsCompoundName()
-
setBuiltin
public void setBuiltin(boolean builtin)
Mark this type as built into the system. Do not use
-
isBuiltin
public boolean isBuiltin()
Returns whether this type is built into the system
-
inherited
public java.util.List<QueryProfileType> inherited()
Returns the query profile types inherited from this (never null). If this profile type is not frozen, this list can be modified to change the set of inherited types. If it is frozen, the returned list is immutable.
-
declaredFields
public java.util.Map<java.lang.String,FieldDescription> declaredFields()
Returns the fields declared in this (i.e not including those inherited) as an immutable map.- Throws:
java.lang.IllegalStateException
- if this is frozen
-
isDeclaredStrict
public boolean isDeclaredStrict()
Returns true if this is declared strict.- Throws:
java.lang.IllegalStateException
- if this is frozen
-
getDeclaredMatchAsPath
public boolean getDeclaredMatchAsPath()
Returns true if this is declared as match as path.- Throws:
java.lang.IllegalStateException
- if this is frozen
-
setStrict
public void setStrict(boolean strict)
Set whether nondeclared fields are permissible. Throws an exception if this is frozen.
-
isStrict
public boolean isStrict()
Returns whether field not declared in this type is permissible in instances. Default is false: Additional values are allowed
-
setMatchAsPath
public void setMatchAsPath(boolean matchAsPath)
Returns whether instances of this should be matched as path names. Throws if this is frozen.
-
getMatchAsPath
public boolean getMatchAsPath()
Returns whether instances of this should be matched as path names. Default is false: Use exact name matching.
-
freeze
public void freeze()
- Specified by:
freeze
in interfacecom.yahoo.component.provider.Freezable
- Overrides:
freeze
in classcom.yahoo.component.provider.FreezableSimpleComponent
-
isOverridable
public boolean isOverridable(java.lang.String fieldName)
Returns whether the given field name is overridable in this type. Default: true (so all non-declared fields returns true)
-
getValueClass
public java.lang.Class<?> getValueClass(java.lang.String name)
Returns the permissible class for the value of the given name in this type- Returns:
- the permissible class for a value,
Object
if all types are legal, null if no types are legal (i.e if the name is not legal)
-
getType
public QueryProfileType getType(java.lang.String localName)
Returns the type of the given query profile type declared as a field in this
-
getFieldType
public FieldType getFieldType(com.yahoo.processing.request.CompoundName name)
Returns the field type of the given name under this, of null if none
-
getField
public FieldDescription getField(java.lang.String name)
Returns the description of the field with the given name in this type or an inherited type (depth first left to right search). Returns null if the field is not defined in this or an inherited profile.
-
removeField
public FieldDescription removeField(java.lang.String fieldName)
Removes a field from this (not from any inherited profile)- Returns:
- the removed field or null if none
- Throws:
java.lang.IllegalStateException
- if this is frozen
-
addField
public void addField(FieldDescription fieldDescription)
Adds a field to this, without associating with a type registry; field descriptions with compound is not be supported.- Throws:
java.lang.IllegalStateException
- if this is frozen
-
addField
public void addField(FieldDescription fieldDescription, QueryProfileTypeRegistry registry)
Adds a field to this- Throws:
java.lang.IllegalStateException
- if this is frozen
-
fields
public java.util.Map<java.lang.String,FieldDescription> fields()
Returns all the fields of this profile type and all types it inherits as a read-only map
-
aliases
public java.util.Map<java.lang.String,java.lang.String> aliases()
Returns the alias to field mapping of this type as a read-only map. This is never null. Note that all keys are lower-cased because aliases are case-insensitive
-
unalias
public java.lang.String unalias(java.lang.String aliasOrField)
Returns the field name of an alias or field name
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Two types are equal if they have the same id- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classcom.yahoo.component.AbstractComponent
-
-