io.sarl.lang.typesystem.cast
Class ObjectAndPrimitiveBasedSelector
All Superinterfaces:
ISelector
Enclosing class:
ObjectAndPrimitiveBasedCastOperationCandidateSelector
protected static class ObjectAndPrimitiveBasedSelector
extends java.lang.Object
implements ISelector
Select the functions that should be called in place of a classic cast operator.

This selector searches for the functions with:
  • the prefix text to for the object types, e.g. toString; and
  • the post-fix text Value for the primitive types, e.g. (intValue.

This selector also applies the following criteria, assuming E is the type of the expression to cast and T is the destination type:
  • T is assignable from the the return value's type.
  • E is assignable from the argument's type.
Maven Group Identifier:
io.sarl.lang
Maven Artifact Identifier:
compiler
Since:
0.9
Constructor Summary
Action Summary
Modifier and type Action and description
protected java.lang.String getValidClassSimpleName(String)
Validate the simple name for class type.
protected java.lang.String getValidPrimitiveSimpleName(String)
Validate the simple name for primitive type.
boolean isCastOperatorCandidate(IIdentifiableElementDescription)
protected boolean isValidParameters(JvmOperation)
Validate the parameters of the operation.
protected boolean isValidReturnType(String,LightweightTypeReference)
Validate the return type of the operation.
Constructor Details
new(AbstractTypeComputationState,LightweightTypeReference,LightweightTypeReference)
protected new(AbstractTypeComputationState,LightweightTypeReference,LightweightTypeReference)
Constructor.
Parameters:
state - the current state of the type computation.
castType - the target type.
expressionType - the type of the expression to cast.
Action Details
getValidClassSimpleName(String)
protected def getValidClassSimpleName(String) : java.lang.String
Validate the simple name for class type.
Parameters:
name - the simple name to validate.
Returns:
the type name part of the name, with the first letter upper case. or null if the name is invalid.
getValidPrimitiveSimpleName(String)
protected def getValidPrimitiveSimpleName(String) : java.lang.String
Validate the simple name for primitive type.
Parameters:
name - the simple name to validate.
Returns:
the type name part of the name, all lower case. or null if the name is invalid.
isCastOperatorCandidate(IIdentifiableElementDescription)
def isCastOperatorCandidate(IIdentifiableElementDescription) : boolean
isValidParameters(JvmOperation)
protected def isValidParameters(JvmOperation) : boolean
Validate the parameters of the operation.
Parameters:
operation - the operation from which the parameters are extracted.
Returns:
true if the return type is valid; otherwise false .
isValidReturnType(String,LightweightTypeReference)
protected def isValidReturnType(String,LightweightTypeReference) : boolean
Validate the return type of the operation.
Parameters:
expectedTypeName - the expected simple name of the return type.
type - the return type.
Returns:
true if the return type is valid; otherwise false .