Class SourceMethod

  • All Implemented Interfaces:

    public class SourceMethod
    extends Object
    implements Method
    Represents a mapping method with source and target type and the mappings between the properties of source and target type.

    A method can either be configured by itself or by another method for the inverse mapping direction (the appropriate setter on MappingMethodOptions will be called in this case).

    Gunnar Morling
    • Method Detail

      • getDeclaringMapper

        public Type getDeclaringMapper()
        Description copied from interface: Method
        Returns the mapper type declaring this method if it is not declared by the mapper interface currently processed but by another mapper imported via Mapper#users().
        Specified by:
        getDeclaringMapper in interface Method
        The declaring mapper type
      • getName

        public String getName()
        Description copied from interface: Method
        Returns then name of the method.
        Specified by:
        getName in interface Method
        method name
      • getSourceParameters

        public List<Parameter> getSourceParameters()
        Description copied from interface: Method
        returns the list of 'true' source parameters excluding the parameter(s) that are designated as target, target type or context parameter.
        Specified by:
        getSourceParameters in interface Method
        list of 'true' source parameters
      • getContextParameters

        public List<Parameter> getContextParameters()
        Description copied from interface: Method
        returns the list of mapping context parameters, i.e. those parameters that are annotated with Context.
        Specified by:
        getContextParameters in interface Method
        list of context parameters
      • getParameterNames

        public List<String> getParameterNames()
        Specified by:
        getParameterNames in interface Method
        the names of the parameters of this mapping method
      • getResultType

        public Type getResultType()
        Description copied from interface: Method
        Returns the type of the result. The result is defined as the type of the parameter designated with MappingTarget, or in absence the return type.
        Specified by:
        getResultType in interface Method
        result type
      • getReturnType

        public Type getReturnType()
        Description copied from interface: Method
        Returns the return type of the method
        Specified by:
        getReturnType in interface Method
        return type
      • inverses

        public boolean inverses​(SourceMethod method)
      • canInheritFrom

        public boolean canInheritFrom​(SourceMethod method)
      • getMappingTargetParameter

        public Parameter getMappingTargetParameter()
        Description copied from interface: Method
        Returns the parameter designated as mapping target (if present) MappingTarget
        Specified by:
        getMappingTargetParameter in interface Method
        mapping target parameter (when present) null otherwise.
      • isObjectFactory

        public boolean isObjectFactory()
        Description copied from interface: Method
        Returns whether the meethod is designated as bean factory for mapping target ObjectFactory
        Specified by:
        isObjectFactory in interface Method
        true if it is a target bean factory.
      • getTargetTypeParameter

        public Parameter getTargetTypeParameter()
        Description copied from interface: Method
        Returns the parameter designated as target type (if present) TargetType
        Specified by:
        getTargetTypeParameter in interface Method
        target type parameter (when present) null otherwise.
      • isIterableMapping

        public boolean isIterableMapping()
      • isStreamMapping

        public boolean isStreamMapping()
      • isMapMapping

        public boolean isMapMapping()
      • isRemovedEnumMapping

        public boolean isRemovedEnumMapping()
        Enum Mapping was realized with @Mapping in stead of @ValueMapping. @Mapping is no longer supported.
        true when @Mapping is used in stead of @ValueMapping
      • isValueMapping

        public boolean isValueMapping()
        The default enum mapping (no mappings specified) will from now on be handled as a value mapping. If there are any @Mapping / @Mappings defined on the method, then the deprecated enum behavior should be executed.
        whether (true) or not (false) to execute value mappings
      • getApplicablePrototypeMethods

        public List<SourceMethod> getApplicablePrototypeMethods()
      • getApplicableReversePrototypeMethods

        public List<SourceMethod> getApplicableReversePrototypeMethods()
      • overridesMethod

        public boolean overridesMethod()
        Whether an implementation of this method must be generated or not.
        Specified by:
        overridesMethod in interface Method
        true when an implementation is required
      • matches

        public boolean matches​(List<Type> sourceTypes,
                               Type targetType)
        Description copied from interface: Method
        Checks whether the provided sourceType and provided targetType match with the parameter respectively return type of the method. The check also should incorporate wild card and generic type variables
        Specified by:
        matches in interface Method
        sourceTypes - the sourceTypes to match to the parameter
        targetType - the targetType to match to the returnType
        true when match
      • containsTargetTypeParameter

        public static boolean containsTargetTypeParameter​(List<Parameter> parameters)
        parameters - the parameter list to check
        true if the parameter list contains a parameter annotated with @TargetType
      • getThrownTypes

        public List<Type> getThrownTypes()
        Description copied from interface: Method
        Returns all exceptions thrown by this method
        Specified by:
        getThrownTypes in interface Method
        exceptions thrown
      • isStatic

        public boolean isStatic()
        Description copied from interface: Method
        Whether this method is static or an instance method
        Specified by:
        isStatic in interface Method
        true when static.
      • isDefault

        public boolean isDefault()
        Description copied from interface: Method
        Whether this method is Java 8 default method
        Specified by:
        isDefault in interface Method
        true when Java 8 default method
      • getDefiningType

        public Type getDefiningType()
        Specified by:
        getDefiningType in interface Method
        the Type (class or interface) that defines this method.
      • isLifecycleCallbackMethod

        public boolean isLifecycleCallbackMethod()
        Specified by:
        isLifecycleCallbackMethod in interface Method
        true, if the method represents a mapping lifecycle callback (Before/After mapping method)
      • isPresenceCheck

        public boolean isPresenceCheck()
        Description copied from interface: Method
        Returns whether the method is designated as a presence check method
        Specified by:
        isPresenceCheck in interface Method
        true if it is a presence check method
      • isAfterMappingMethod

        public boolean isAfterMappingMethod()
      • isBeforeMappingMethod

        public boolean isBeforeMappingMethod()
      • isAbstract

        public boolean isAbstract()
        returns true for interface methods (see jls 9.4) lacking a default or static modifier and for abstract methods
      • isUpdateMethod

        public boolean isUpdateMethod()
        Specified by:
        isUpdateMethod in interface Method
        true, if the method is an update method, i.e. it has a parameter annotated with @MappingTarget.
      • hasObjectFactoryAnnotation

        public boolean hasObjectFactoryAnnotation()
      • getTypeParameters

        public List<Type> getTypeParameters()
        Description copied from interface: Method
        Returns the formal type parameters of this method in declaration order.
        Specified by:
        getTypeParameters in interface Method
        the formal type parameters, or an empty list if there are none
      • describe

        public String describe()
        Specified by:
        describe in interface Method
        the short name for error messages when verbose, full name when not