Class SourceMethod
java.lang.Object
org.mapstruct.ap.internal.model.source.SourceMethod
- All Implemented Interfaces:
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).
- Author:
- Gunnar Morling
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleancanInheritFrom(SourceMethod method) static booleancontainsTargetTypeParameter(List<Parameter> parameters) describe()Returns theAccessibilityof this method.returns the list of mapping context parameters, i.e. those parameters that are annotated withContext.Returns the mapper type declaring this method if it is not declared by the mapper interface currently processed but by another mapper imported viaMapper#users().Returns the parameter designated as mapping target (if present)MappingTargetgetName()Returns then name of the method.In contrast toMethod.getSourceParameters()this method returns all parametersReturns the type of the result.Returns the return type of the methodreturns the list of 'true' source parameters excluding the parameter(s) that are designated as target, target type or context parameter.Returns the parameter designated as target type (if present)TargetTypeReturns all exceptions thrown by this methodReturns the formal type parameters of this method in declaration order.booleanbooleaninverses(SourceMethod method) booleanbooleanbooleanbooleanWhether this method is Java 8 default methodbooleanbooleanbooleanbooleanReturns whether the method is designated as bean factory for mapping targetObjectFactorybooleanEnum Mapping was realized with @Mapping in stead of @ValueMapping.booleanisStatic()Whether this method is static or an instance methodbooleanbooleanbooleanThe default enum mapping (no mappings specified) will from now on be handled as a value mapping.booleanChecks whether the provided sourceType and provided targetType match with the parameter respectively return type of the method.booleanWhether an implementation of this method must be generated or not.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.mapstruct.ap.internal.model.source.Method
getMappingSourceType
-
Method Details
-
getDeclaringMapper
Description copied from interface:MethodReturns the mapper type declaring this method if it is not declared by the mapper interface currently processed but by another mapper imported viaMapper#users().- Specified by:
getDeclaringMapperin interfaceMethod- Returns:
- The declaring mapper type
-
getExecutable
- Specified by:
getExecutablein interfaceMethod
-
getName
Description copied from interface:MethodReturns then name of the method. -
getParameters
Description copied from interface:MethodIn contrast toMethod.getSourceParameters()this method returns all parameters- Specified by:
getParametersin interfaceMethod- Returns:
- all parameters
-
getSourceParameters
Description copied from interface:Methodreturns the list of 'true' source parameters excluding the parameter(s) that are designated as target, target type or context parameter.- Specified by:
getSourceParametersin interfaceMethod- Returns:
- list of 'true' source parameters
-
getContextParameters
Description copied from interface:Methodreturns the list of mapping context parameters, i.e. those parameters that are annotated withContext.- Specified by:
getContextParametersin interfaceMethod- Returns:
- list of context parameters
-
getContextProvidedMethods
- Specified by:
getContextProvidedMethodsin interfaceMethod- Returns:
- a mapping between
Method.getContextParameters()to factory and lifecycle methods provided by them.
-
getParameterNames
- Specified by:
getParameterNamesin interfaceMethod- Returns:
- the names of the parameters of this mapping method
-
getResultType
Description copied from interface:MethodReturns the type of the result. The result is defined as the type of the parameter designated withMappingTarget, or in absence the return type.- Specified by:
getResultTypein interfaceMethod- Returns:
- result type
-
getReturnType
Description copied from interface:MethodReturns the return type of the method- Specified by:
getReturnTypein interfaceMethod- Returns:
- return type
-
getAccessibility
Description copied from interface:MethodReturns theAccessibilityof this method.- Specified by:
getAccessibilityin interfaceMethod- Returns:
- the
Accessibilityof this method
-
inverses
-
canInheritFrom
-
getMappingTargetParameter
Description copied from interface:MethodReturns the parameter designated as mapping target (if present)MappingTarget- Specified by:
getMappingTargetParameterin interfaceMethod- Returns:
- mapping target parameter (when present) null otherwise.
-
isObjectFactory
public boolean isObjectFactory()Description copied from interface:MethodReturns whether the method is designated as bean factory for mapping targetObjectFactory- Specified by:
isObjectFactoryin interfaceMethod- Returns:
- true if it is a target bean factory.
-
getTargetTypeParameter
Description copied from interface:MethodReturns the parameter designated as target type (if present)TargetType- Specified by:
getTargetTypeParameterin interfaceMethod- Returns:
- target type parameter (when present) null otherwise.
-
getSourcePropertyNameParameter
-
getTargetPropertyNameParameter
-
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.- Returns:
- 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.- Returns:
- whether (true) or not (false) to execute value mappings
-
toString
-
getApplicablePrototypeMethods
-
getApplicableReversePrototypeMethods
-
overridesMethod
public boolean overridesMethod()Whether an implementation of this method must be generated or not.- Specified by:
overridesMethodin interfaceMethod- Returns:
- true when an implementation is required
-
matches
Description copied from interface:MethodChecks 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 -
containsTargetTypeParameter
- Parameters:
parameters- the parameter list to check- Returns:
trueif the parameter list contains a parameter annotated with@TargetType
-
getThrownTypes
Description copied from interface:MethodReturns all exceptions thrown by this method- Specified by:
getThrownTypesin interfaceMethod- Returns:
- exceptions thrown
-
getOptions
- Specified by:
getOptionsin interfaceMethod- Returns:
- the mapping options for this method
-
getConditionOptions
- Specified by:
getConditionOptionsin interfaceMethod
-
isStatic
public boolean isStatic()Description copied from interface:MethodWhether this method is static or an instance method -
isDefault
public boolean isDefault()Description copied from interface:MethodWhether this method is Java 8 default method -
getDefiningType
- Specified by:
getDefiningTypein interfaceMethod- Returns:
- the Type (class or interface) that defines this method.
-
isLifecycleCallbackMethod
public boolean isLifecycleCallbackMethod()- Specified by:
isLifecycleCallbackMethodin interfaceMethod- Returns:
true, if the method represents a mapping lifecycle callback (Before/After mapping method)
-
isAfterMappingMethod
public boolean isAfterMappingMethod() -
isBeforeMappingMethod
public boolean isBeforeMappingMethod() -
isAbstract
public boolean isAbstract()- Returns:
- 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:
isUpdateMethodin interfaceMethod- Returns:
true, if the method is an update method, i.e. it has a parameter annotated with@MappingTarget.
-
hasObjectFactoryAnnotation
public boolean hasObjectFactoryAnnotation() -
getTypeParameters
Description copied from interface:MethodReturns the formal type parameters of this method in declaration order.- Specified by:
getTypeParametersin interfaceMethod- Returns:
- the formal type parameters, or an empty list if there are none
-
describe
-