Class BuiltInMethod
java.lang.Object
org.mapstruct.ap.internal.model.source.builtin.BuiltInMethod
- All Implemented Interfaces:
Method
- Direct Known Subclasses:
AbstractToXmlGregorianCalendar,CalendarToZonedDateTime,XmlGregorianCalendarToCalendar,XmlGregorianCalendarToDate,XmlGregorianCalendarToJodaDateTime,XmlGregorianCalendarToJodaLocalDate,XmlGregorianCalendarToJodaLocalDateTime,XmlGregorianCalendarToJodaLocalTime,XmlGregorianCalendarToLocalDate,XmlGregorianCalendarToLocalDateTime,XmlGregorianCalendarToString,ZonedDateTimeToCalendar
Represents a "built-in" mapping method which will be added as private method to the generated mapper. Built-in
methods are used in cases where a simple conversation doesn't suffice, e.g. as several lines of source code or a
try/catch block are required.
- Author:
- Sjaak Derksen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescribe()booleandoTypeVarsMatch(Type parameter, Type returnType) Analyzes the Java Generic type variables in the parameter do match the type variables in the build in method same goes for the returnType.booleanequals based on classReturns theAccessibilityof this method.getContextParameter(ConversionContext conversionContext) the conversion context is used to format an auxiliary parameter in the method call with context specific information such as a date format.returns the list of mapping context parameters, i.e. those parameters that are annotated withContext.final TypeReturns 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 types used by this method for which import statements need to be generated.mapping target parameter mechanism not supported for built-in methodsgetName()Returns then name of the method.abstract ParameterThere's currently only one parameter foreseen instead of a list of parameterIn contrast toMethod.getSourceParameters()this method returns all parametersReturns the type of the result.returns the list of 'true' source parameters excluding the parameter(s) that are designated as target, target type or context parameter.target type parameter mechanism not supported for built-in methodsReturns all exceptions thrown by this methodReturns the formal type parameters of this method in declaration order.inthashCode()hashCode based on classbooleanWhether this method is Java 8 default methodbooleanbooleanobject factory mechanism not supported for built-in methodsbooleanisStatic()Whether this method is static or an instance methodbooleanbooleanChecks whether the provided sourceType and provided targetType match with the parameter respectively return type of the method.booleanWhether this method overrides an abstract method.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mapstruct.ap.internal.model.source.Method
getConditionOptions, getMappingSourceType, getReturnType
-
Constructor Details
-
BuiltInMethod
public BuiltInMethod()
-
-
Method Details
-
getName
Returns then name of the method. -
getImportTypes
Returns the types used by this method for which import statements need to be generated. Defaults to the empty set. To be overridden by implementations in case they make use of additional types (note that the parameter and return type don't need to be added).- Returns:
- the types used by this method for which import statements need to be generated
-
matches
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 variablesDefault the targetType should be assignable to the returnType and the sourceType to the parameter, excluding generic type variables. When the implementor sees a need for this, this method can be overridden.
-
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.
-
getDeclaringMapper
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().For built-in methods, the declaring mapper is always
nullas they will be added as private methods to the generated mapper.- Specified by:
getDeclaringMapperin interfaceMethod- Returns:
null
-
getParameters
Description copied from interface:MethodIn contrast toMethod.getSourceParameters()this method returns all parameters- Specified by:
getParametersin interfaceMethod- Returns:
- all parameters
-
getMappingTargetParameter
mapping target parameter mechanism not supported for built-in methods- Specified by:
getMappingTargetParameterin interfaceMethod- Returns:
null
-
getTargetTypeParameter
target type parameter mechanism not supported for built-in methods- Specified by:
getTargetTypeParameterin interfaceMethod- Returns:
null
-
isObjectFactory
public boolean isObjectFactory()object factory mechanism not supported for built-in methods- Specified by:
isObjectFactoryin interfaceMethod- Returns:
- false
-
getContextParameter
the conversion context is used to format an auxiliary parameter in the method call with context specific information such as a date format.- Parameters:
conversionContext- context- Returns:
- null if no context parameter should be included "null" if there should be an explicit null call "'dateFormat'" for instance, to indicate how the build-in method should format the date
-
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
-
hashCode
public int hashCode()hashCode based on class -
equals
equals based on class -
doTypeVarsMatch
Analyzes the Java Generic type variables in the parameter do match the type variables in the build in method same goes for the returnType.- Parameters:
parameter- sourcereturnType- target- Returns:
true, iff the type variables match
-
getParameter
There's currently only one parameter foreseen instead of a list of parameter- Returns:
- the parameter
-
getAccessibility
Description copied from interface:MethodReturns theAccessibilityof this method.- Specified by:
getAccessibilityin interfaceMethod- Returns:
- the
Accessibilityof this method
-
getThrownTypes
Description copied from interface:MethodReturns all exceptions thrown by this method- Specified by:
getThrownTypesin interfaceMethod- Returns:
- exceptions thrown
-
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
-
getParameterNames
- Specified by:
getParameterNamesin interfaceMethod- Returns:
- the names of the parameters of this mapping method
-
overridesMethod
public boolean overridesMethod()Description copied from interface:MethodWhether this method overrides an abstract method.- Specified by:
overridesMethodin interfaceMethod- Returns:
- true when an abstract method is overridden.
-
getExecutable
- Specified by:
getExecutablein 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)
-
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.
-
getOptions
- Specified by:
getOptionsin interfaceMethod- Returns:
- the mapping options for this method
-
getFieldReference
-
getConstructorFragment
-
describe
-