Class TypeSelector

  • All Implemented Interfaces:
    MethodSelector

    public class TypeSelector
    extends java.lang.Object
    implements MethodSelector
    Selects those methods from the given input set which match the given source and target types (via MethodMatcher).
    • Method Detail

      • getMatchingMethods

        public <T extends Method> java.util.List<SelectedMethod<T>> getMatchingMethods​(Method mappingMethod,
                                                                                       java.util.List<SelectedMethod<T>> methods,
                                                                                       java.util.List<Type> sourceTypes,
                                                                                       Type mappingTargetType,
                                                                                       Type returnType,
                                                                                       SelectionCriteria criteria)
        Description copied from interface: MethodSelector
        Selects those methods which match the given types and other criteria
        Specified by:
        getMatchingMethods in interface MethodSelector
        Type Parameters:
        T - either SourceMethod or BuiltInMethod
        Parameters:
        mappingMethod - mapping method, defined in Mapper for which this selection is carried out
        methods - list of available methods
        sourceTypes - parameter type(s) that should be matched
        mappingTargetType - mappingTargetType that should be matched
        returnType - return type that should be matched
        criteria - criteria used in the selection process
        Returns:
        list of methods that passes the matching process
      • getAvailableParameterBindingsFromMethod

        private java.util.List<ParameterBinding> getAvailableParameterBindingsFromMethod​(Method method,
                                                                                         Type targetType,
                                                                                         SourceRHS sourceRHS)
      • getAvailableParameterBindingsFromSourceTypes

        private java.util.List<ParameterBinding> getAvailableParameterBindingsFromSourceTypes​(java.util.List<Type> sourceTypes,
                                                                                              Type targetType,
                                                                                              Method mappingMethod)
      • addMappingTargetAndTargetTypeBindings

        private void addMappingTargetAndTargetTypeBindings​(java.util.List<ParameterBinding> availableParams,
                                                           Type targetType)
        Adds default parameter bindings for the mapping-target and target-type if not already available.
        Parameters:
        availableParams - Already available params, new entries will be added to this list
        targetType - Target type
      • parameterBindingNotMatchesParameterVariableNames

        private boolean parameterBindingNotMatchesParameterVariableNames​(java.util.List<ParameterBinding> parameterBindings,
                                                                         java.util.List<Parameter> parameters)
        Checks if the given parameter-bindings have the same variable name than the given parameters.
        The first entry in the parameter-bindings belongs to the first entry in the parameters and so on.
        Parameters:
        parameterBindings - List of parameter bindings
        parameters - List of parameters, must have the same size than the parameterBindings list
        Returns:
        true as soon as there is a parameter with a different variable name than the binding
      • getCandidateParameterBindingPermutations

        private static java.util.List<java.util.List<ParameterBinding>> getCandidateParameterBindingPermutations​(java.util.List<ParameterBinding> availableParams,
                                                                                                                 java.util.List<Parameter> methodParameters)
        Parameters:
        availableParams - parameter bindings available in the scope of the method call
        methodParameters - parameters of the method that is inspected
        Returns:
        all parameter binding permutations for which proper type checks need to be conducted.
      • findCandidateBindingsForParameter

        private static java.util.List<ParameterBinding> findCandidateBindingsForParameter​(java.util.List<ParameterBinding> candidateParameters,
                                                                                          Parameter parameter)
        Parameters:
        candidateParameters - available for assignment.
        parameter - that need assignment from one of the candidate parameter bindings.
        Returns:
        list of candidate parameter bindings that might be assignable.
      • extractTypes

        private static java.util.List<Type> extractTypes​(java.util.List<ParameterBinding> parameters)