Class FieldType
- java.lang.Object
-
- com.yahoo.search.query.profile.types.FieldType
-
- Direct Known Subclasses:
PrimitiveFieldType
,QueryFieldType
,QueryProfileFieldType
,TensorFieldType
public abstract class FieldType extends Object
Superclass of query type field types. Field types are immutable.- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static PrimitiveFieldType
booleanType
static PrimitiveFieldType
doubleType
static PrimitiveFieldType
floatType
static QueryProfileFieldType
genericQueryProfileType
static PrimitiveFieldType
integerType
static PrimitiveFieldType
longType
static QueryFieldType
queryType
static PrimitiveFieldType
stringType
-
Constructor Summary
Constructors Constructor Description FieldType()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.yahoo.tensor.TensorType
asTensorType()
Returns this type as a tensor type: The true tensor type is this is a tensor field an an empty type - interpreted as a double in numerical contexts - otherwiseabstract Object
convertFrom(Object o, QueryProfileRegistry registry)
Converts the given type to an instance of this type, if possible.abstract Object
convertFrom(Object o, ConversionContext context)
Converts the given type to an instance of this type, if possible.static FieldType
fromString(String typeString, QueryProfileTypeRegistry registry)
Returns the field type for a given string name.abstract Class
getValueClass()
Returns the class of instance values of this field typestatic boolean
isLegalFieldValue(Object value)
Returns true if the given object is a legal field value of some field value typeabstract String
stringValue()
Returns a string representation of this type which can be converted back to a type class byfromString(java.lang.String, com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)
abstract String
toInstanceDescription()
Returns a string describing possible instances of this type, suitable for user error messagesabstract String
toString()
-
-
-
Field Detail
-
stringType
public static final PrimitiveFieldType stringType
-
integerType
public static final PrimitiveFieldType integerType
-
longType
public static final PrimitiveFieldType longType
-
floatType
public static final PrimitiveFieldType floatType
-
doubleType
public static final PrimitiveFieldType doubleType
-
booleanType
public static final PrimitiveFieldType booleanType
-
queryType
public static final QueryFieldType queryType
-
genericQueryProfileType
public static final QueryProfileFieldType genericQueryProfileType
-
-
Method Detail
-
getValueClass
public abstract Class getValueClass()
Returns the class of instance values of this field type
-
stringValue
public abstract String stringValue()
Returns a string representation of this type which can be converted back to a type class byfromString(java.lang.String, com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)
-
toInstanceDescription
public abstract String toInstanceDescription()
Returns a string describing possible instances of this type, suitable for user error messages
-
convertFrom
public abstract Object convertFrom(Object o, QueryProfileRegistry registry)
Converts the given type to an instance of this type, if possible. Returns null if not possible.
-
convertFrom
public abstract Object convertFrom(Object o, ConversionContext context)
Converts the given type to an instance of this type, if possible. Returns null if not possible.
-
asTensorType
public com.yahoo.tensor.TensorType asTensorType()
Returns this type as a tensor type: The true tensor type is this is a tensor field an an empty type - interpreted as a double in numerical contexts - otherwise
-
fromString
public static FieldType fromString(String typeString, QueryProfileTypeRegistry registry)
Returns the field type for a given string name.- Parameters:
typeString
- a type string - a primitive name, "query-profile" or "query-profile:profile-name"registry
- the registry in which query profile references are resolved when the last form above is used, or null in which case that form cannot be used- Throws:
IllegalArgumentException
- if the string does not resolve to a type
-
isLegalFieldValue
public static boolean isLegalFieldValue(Object value)
Returns true if the given object is a legal field value of some field value type
-
-