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
BooleanValueand 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
AnalyticsValues are passed as the if-else parameters, anAnalyticsValuewill be returned. If either parameter isn't single-valued, aAnalyticsValueStreamwill 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.CreatorFunctioncreatorFunctionstatic Stringname
-
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 StringgetExpressionStr()Get the expression string of the analytics value stream.AnalyticsValueStream.ExpressionTypegetExpressionType()Get the type of the expression that this class represents.StringgetName()Get the name of function or value.voidstreamObjects(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 org.apache.solr.common.SolrException
- Throws:
org.apache.solr.common.SolrException
-
-
Method Detail
-
streamObjects
public void streamObjects(Consumer<Object> cons)
Description copied from interface:AnalyticsValueStreamStream 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:AnalyticsValueStreamGet the name of function or value.- Returns:
- the name of function/value
-
getExpressionStr
public String getExpressionStr()
Description copied from interface:AnalyticsValueStreamGet 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:AnalyticsValueStreamGet the type of the expression that this class represents.- Returns:
- the expression type
-
-