Package gw.lang.parser.coercers
Class FunctionToInterfaceCoercer
java.lang.Object
gw.lang.parser.coercers.BaseCoercer
gw.lang.parser.coercers.FunctionToInterfaceCoercer
- All Implemented Interfaces:
ICoercer
,IResolvingCoercer
-
Field Summary
FieldsFields inherited from interface gw.lang.parser.ICoercer
MAX_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncoerceValue
(IType typeToCoerceTo, Object value) private IType
extractReturnTypeFromInterface
(IType target) int
getPriority
(IType to, IType from) static IFunctionType
getRepresentativeFunctionType
(IType interfaceType) static IMethodInfo
getSingleMethod
(IType interfaceType) static IJavaClassMethod
getSingleMethodFromJavaInterface
(IJavaClassInfo interfaceType) static IJavaClassMethod
getSingleMethodFromJavaInterface
(IJavaType interfaceType) boolean
private static boolean
hasMethod
(IJavaClassInfo jci, String name, IJavaClassInfo[] params) static FunctionToInterfaceCoercer
instance()
boolean
resolveType
(IType target, IType source) This method should produce a more appropriately parameterized type for the given target type for this coercion.
-
Field Details
-
_instance
-
-
Constructor Details
-
FunctionToInterfaceCoercer
private FunctionToInterfaceCoercer()
-
-
Method Details
-
instance
-
coerceValue
- Specified by:
coerceValue
in interfaceICoercer
-
getRepresentativeFunctionType
-
getSingleMethod
-
getSingleMethodFromJavaInterface
-
getSingleMethodFromJavaInterface
-
hasMethod
-
isExplicitCoercion
public boolean isExplicitCoercion()- Specified by:
isExplicitCoercion
in interfaceICoercer
-
handlesNull
public boolean handlesNull()- Specified by:
handlesNull
in interfaceICoercer
- Returns:
- true if this coercer knows how to handle the null value.
-
getPriority
- Specified by:
getPriority
in interfaceICoercer
- Returns:
- a value between 0 and MAX_PRIORITY, inclusive that indicates the priority of this coercer when resolving overloaded methods. Typically a coercer should return 0, but coercers that have a high affinity between the target and coerced type, such as primitives, can have higher priorities.
-
resolveType
Description copied from interface:IResolvingCoercer
This method should produce a more appropriately parameterized type for the given target type for this coercion. This allows a coercion to communicate type information through the coercion process. An example is the MetaType-to-Class coercion. MetaType
should be interpreted as Class from a type inference perspective, so this give the coercer a chance to let the compiler know so. If no more appropriate inference type exists, this method should return the source type.
- Specified by:
resolveType
in interfaceIResolvingCoercer
- Parameters:
target
- type- Returns:
- a possibly more appropriately parameterized type or the source type if not
-
extractReturnTypeFromInterface
-