Class ScopedLambdaType
- All Implemented Interfaces:
Type
A LambdaType
that also includes the scope. Mostly used to facilitate the mechanics of realizing the
body of a lambda expression during function realization.
-
Constructor Summary
ConstructorDescriptionScopedLambdaType
(Struct struct, String... args) ScopedLambdaType
(Struct scopeType, List<String> args) -
Method Summary
Modifier and TypeMethodDescriptionasStruct()
buildCallingScopeType
(Type... lambdaArgTypes) Builds a scope that includes the lambda args (based on the actual types that the lambda expression is realized with), and returns the scope type.Attempt to convert the given value in to one represented by this type.boolean
int
estimateSize
(Object entry) Estimate the number of bytes used to serialize the given value to an output stream.getArgs()
The names of the arguments that are passed to the expression.int
getArity()
The scope (or input type) that was closed over when the expression that contained this lambda expression was realizedint
hashCode()
Class<?>
The underlying java class used to represent this type.void
toBytes
(DataOutputStream os, Object toWrite) toString()
<T,
U> U visit
(TypeVisitor<T, U> tv, T data) Type specific visiting logic.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.types.Type
checkForNull, find, findAllowNull, getUnwrappedType, isA, isNullable, isNumeric, isWrapped, toString, unwrap
-
Constructor Details
-
ScopedLambdaType
-
ScopedLambdaType
-
-
Method Details
-
getArity
public int getArity()- Returns:
- the number of arguments the expression declared.
-
asStruct
-
coerce
Description copied from interface:Type
Attempt to convert the given value in to one represented by this type.
- Specified by:
coerce
in interfaceType
- Parameters:
value
- The value to coerce- Returns:
- A value that conforms to this type
- Throws:
CoercionException
- if the given object can not be converted to something represented by this type
-
internalType
Description copied from interface:Type
The underlying java class used to represent this type.
- Specified by:
internalType
in interfaceType
-
estimateSize
Description copied from interface:Type
Estimate the number of bytes used to serialize the given value to an output stream.
- Specified by:
estimateSize
in interfaceType
- Parameters:
entry
- the value of this type to measure. Must be ofType.internalType()
or aClassCastException
is going to happen- Returns:
- the estimated number of bytes, or zero if no estimation was possible.
-
toBytes
- Specified by:
toBytes
in interfaceType
- Throws:
IOException
-
fromBytes
- Specified by:
fromBytes
in interfaceType
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-
visit
Description copied from interface:Type
Type specific visiting logic. Types must decide whether they are atomic or compound and call the relevant method on
TypeVisitor
. It's up to each compound type to decide how they want to structure their children, e.g. order, metadata, and what's considered a child or not. -
buildCallingScopeType
Builds a scope that includes the lambda args (based on the actual types that the lambda expression is realized with), and returns the scope type.
- Parameters:
lambdaArgTypes
- the actual types of the lambda arguments- Returns:
- a Struct combining
getScopeType()
and lambdaArgTypes
-
getScopeType
The scope (or input type) that was closed over when the expression that contained this lambda expression was realized
-
getArgs
The names of the arguments that are passed to the expression. Once a Lambda is realized, these names become part of the type's identity and so matter for equality
-