Record Class ScalarFunctionSymbol
java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.function.ScalarFunctionSymbol
- Record Components:
namespace- the namespace this symbol belongs to; must not be blankdeclaredName- the name as written by the user; must not be blankprovenance- built-in or user-defined; must not be nullshadowPolicy- replacement policy; must not be nullparameters- ordered parameter definitions; must not be nullreturnType- the scalar type returned; must not be nullproperties- optimizer hint flags; must not be nullbody- the expression body for user-defined functions; absent for opaque built-ins
- All Implemented Interfaces:
FunctionSymbol,Symbol
public record ScalarFunctionSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, List<ParameterDefinition> parameters, ScalarType returnType, Set<FunctionProperty> properties, Optional<Operand> body)
extends Record
implements FunctionSymbol
A scalar function symbol — a function that accepts zero or more scalar arguments
and returns a single scalar value.
Both built-in and user-defined functions are represented by this type; the
Provenance field distinguishes them.
Built-in functions typically have an absent body(), while user-defined
functions carry the body as a parsed Operand expression.
Construction
Use the builder(String) factory to avoid specifying every optional field:
// A built-in, deterministic, pure absolute-value function
ScalarFunctionSymbol abs = ScalarFunctionSymbol.builder("abs")
.namespace("builtin")
.provenance(Provenance.BUILTIN)
.shadowPolicy(ShadowPolicy.FORBIDDEN)
.parameter("x", ScalarType.NUMBER)
.returnType(ScalarType.NUMBER)
.property(FunctionProperty.PURE)
.property(FunctionProperty.DETERMINISTIC)
.build();
// A user-defined function with a body expression
ScalarFunctionSymbol discount = ScalarFunctionSymbol.builder("discount")
.parameter("price", ScalarType.NUMBER)
.parameter("pct", ScalarType.NUMBER)
.returnType(ScalarType.NUMBER)
.body(arith(attr("price"), ArithmeticOperator.MULTIPLY,
arith(num("1"), ArithmeticOperator.MINUS,
arith(attr("pct"), ArithmeticOperator.DIVIDE, num("100")))))
.build();
Both the parameter list and the property set are defensive-copied on construction; the record is therefore immutable.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionScalarFunctionSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, List<ParameterDefinition> parameters, ScalarType returnType, Set<FunctionProperty> properties, Optional<Operand> body) Creates an instance of aScalarFunctionSymbolrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the value of thebodyrecord component.static ScalarFunctionSymbol.BuilderReturns a newScalarFunctionSymbol.Builderfor constructing aScalarFunctionSymbolwith the given declared name.Returns the value of thedeclaredNamerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thenamespacerecord component.Returns the value of theparametersrecord component.Returns the value of thepropertiesrecord component.Returns the value of theprovenancerecord component.Returns the value of thereturnTyperecord component.Returns the value of theshadowPolicyrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.symbol.function.FunctionSymbol
parameterSignatureMethods inherited from interface com.darkcollective.relix.symbol.Symbol
canonicalName
-
Constructor Details
-
ScalarFunctionSymbol
public ScalarFunctionSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, List<ParameterDefinition> parameters, ScalarType returnType, Set<FunctionProperty> properties, Optional<Operand> body) Creates an instance of aScalarFunctionSymbolrecord class.- Parameters:
namespace- the value for thenamespacerecord componentdeclaredName- the value for thedeclaredNamerecord componentprovenance- the value for theprovenancerecord componentshadowPolicy- the value for theshadowPolicyrecord componentparameters- the value for theparametersrecord componentreturnType- the value for thereturnTyperecord componentproperties- the value for thepropertiesrecord componentbody- the value for thebodyrecord component
-
-
Method Details
-
builder
Returns a newScalarFunctionSymbol.Builderfor constructing aScalarFunctionSymbolwith the given declared name.Defaults applied by the builder:
namespace→"default"provenance→Provenance.USERshadowPolicy→ShadowPolicy.PERMITTEDreturnType→ScalarType.ANYparameters→ empty list (zero-argument function)properties→ empty setbody→Optional.empty()
- Parameters:
name- the declared function name; must not be blank- Returns:
- a fresh builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
namespace
Returns the value of thenamespacerecord component. -
declaredName
Returns the value of thedeclaredNamerecord component.- Specified by:
declaredNamein interfaceSymbol- Returns:
- the value of the
declaredNamerecord component
-
provenance
Returns the value of theprovenancerecord component.- Specified by:
provenancein interfaceSymbol- Returns:
- the value of the
provenancerecord component
-
shadowPolicy
Returns the value of theshadowPolicyrecord component.- Specified by:
shadowPolicyin interfaceSymbol- Returns:
- the value of the
shadowPolicyrecord component
-
parameters
Returns the value of theparametersrecord component.- Specified by:
parametersin interfaceFunctionSymbol- Returns:
- the value of the
parametersrecord component
-
returnType
Returns the value of thereturnTyperecord component.- Specified by:
returnTypein interfaceFunctionSymbol- Returns:
- the value of the
returnTyperecord component
-
properties
Returns the value of thepropertiesrecord component.- Specified by:
propertiesin interfaceFunctionSymbol- Returns:
- the value of the
propertiesrecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-