Class IfFunction
- java.lang.Object
-
- org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream
-
- org.apache.solr.analytics.function.mapping.IfFunction
-
- All Implemented Interfaces:
AnalyticsValueStream
public class IfFunction extends AnalyticsValueStream.AbstractAnalyticsValueStream
An if-else mapping function.Three arguments are required. The first, the conditional parameter, must be a
BooleanValue
and the later two, the if and else parameters, can be any type ofAnalyticsValueStream
. For each document, if the conditional value is true then the if-value is used otherwise the else-value is used.The resulting Value or ValueStream will be typed with the closest super-type of the two non-conditional parameters. (e.g. "if"(boolean,double,int) will return a double) If two
AnalyticsValue
s are passed as the if-else parameters, anAnalyticsValue
will be returned. If either parameter isn't single-valued, aAnalyticsValueStream
will be returned.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.analytics.value.AnalyticsValueStream
AnalyticsValueStream.AbstractAnalyticsValueStream, AnalyticsValueStream.ExpressionType
-
-
Field Summary
Fields Modifier and Type Field Description static ExpressionFactory.CreatorFunction
creatorFunction
static String
name
-
Constructor Summary
Constructors Constructor Description IfFunction(BooleanValue ifExpr, AnalyticsValueStream thenExpr, AnalyticsValueStream elseExpr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getExpressionStr()
Get the expression string of the analytics value stream.AnalyticsValueStream.ExpressionType
getExpressionType()
Get the type of the expression that this class represents.String
getName()
Get the name of function or value.void
streamObjects(Consumer<Object> cons)
Stream the object representations of all current values, if any exist.-
Methods inherited from class org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream
convertToConstant
-
-
-
-
Field Detail
-
name
public static final String name
- See Also:
- Constant Field Values
-
creatorFunction
public static final ExpressionFactory.CreatorFunction creatorFunction
-
-
Constructor Detail
-
IfFunction
public IfFunction(BooleanValue ifExpr, AnalyticsValueStream thenExpr, AnalyticsValueStream elseExpr) throws SolrException
- Throws:
SolrException
-
-
Method Detail
-
streamObjects
public void streamObjects(Consumer<Object> cons)
Description copied from interface:AnalyticsValueStream
Stream the object representations of all current values, if any exist.- Parameters:
cons
- The consumer to accept the values
-
getName
public String getName()
Description copied from interface:AnalyticsValueStream
Get the name of function or value.- Returns:
- the name of function/value
-
getExpressionStr
public String getExpressionStr()
Description copied from interface:AnalyticsValueStream
Get the expression string of the analytics value stream. Must be unique to the expression. If passed toExpressionFactory.createExpression(String)
, the exact same expression should be created.- Returns:
- the name of function/value
-
getExpressionType
public AnalyticsValueStream.ExpressionType getExpressionType()
Description copied from interface:AnalyticsValueStream
Get the type of the expression that this class represents.- Returns:
- the expression type
-
-