Package org.mapstruct.ap.internal.model
Class TypeConversion
- java.lang.Object
-
- org.mapstruct.ap.internal.writer.FreeMarkerWritable
-
- org.mapstruct.ap.internal.model.common.ModelElement
-
- org.mapstruct.ap.internal.model.TypeConversion
-
- All Implemented Interfaces:
Assignment,Writable
public class TypeConversion extends ModelElement implements Assignment
An inline conversion between source and target type of a mapping.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.mapstruct.ap.internal.model.common.Assignment
Assignment.AssignmentType
-
Nested classes/interfaces inherited from interface org.mapstruct.ap.internal.writer.Writable
Writable.Context
-
-
Field Summary
Fields Modifier and Type Field Description private AssignmentassignmentA reference to mapping method in case this is a two-step mapping, e.g.private java.lang.StringcloseExpressionprivate java.util.Set<Type>importTypesprivate java.lang.StringopenExpressionprivate static java.lang.StringSOURCE_REFERENCE_PATTERNprivate java.util.List<Type>thrownTypes
-
Constructor Summary
Constructors Constructor Description TypeConversion(java.util.Set<Type> importTypes, java.util.List<Type> exceptionTypes, java.lang.String expression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcreateUniqueVarName(java.lang.String desiredName)Creates an unique safe (local) variable name.AssignmentgetAssignment()java.lang.StringgetCloseExpression()java.util.Set<Type>getImportTypes()Returns a set containing thoseTypes referenced by this model element for which an import statement needs to be declared.java.lang.StringgetOpenExpression()java.lang.StringgetSourceLocalVarName()java.lang.StringgetSourceLoopVarName()SeeAssignment.getSourceLoopVarName()(java.lang.String) }java.lang.StringgetSourceParameterName()Returns the source parameter name, to which this assignment applies.PresenceCheckgetSourcePresenceCheckerReference()the source presence checker referencejava.lang.StringgetSourceReference()the source reference being a source-getter, a constant, nested method call, etc.TypegetSourceType()the source type used in the matching processjava.util.List<Type>getThrownTypes()returns all types exception types thrown by this assignment.Assignment.AssignmentTypegetType()Returns whether the type of assignmentbooleanisCallingUpdateMethod()booleanisSourceReferenceParameter()voidsetAssignment(Assignment assignment)An assignment in itself can wrap another assignment.voidsetSourceLocalVarName(java.lang.String sourceLocalVarName)Replaces the sourceReference at the call site in the assignment in the template with this sourceLocalVarName.voidsetSourceLoopVarName(java.lang.String sourceLoopVarName)Replaces the sourceLocalVar or sourceReference at the call site in the assignment in the template with this sourceLoopVarName.java.lang.StringtoString()-
Methods inherited from class org.mapstruct.ap.internal.writer.FreeMarkerWritable
getTemplateName, getTemplateNameForClass, write
-
-
-
-
Field Detail
-
SOURCE_REFERENCE_PATTERN
private static final java.lang.String SOURCE_REFERENCE_PATTERN
- See Also:
- Constant Field Values
-
importTypes
private final java.util.Set<Type> importTypes
-
thrownTypes
private final java.util.List<Type> thrownTypes
-
openExpression
private final java.lang.String openExpression
-
closeExpression
private final java.lang.String closeExpression
-
assignment
private Assignment assignment
A reference to mapping method in case this is a two-step mapping, e.g. fromJAXBElement<Bar>toFooto for which a nested method call will be generated:setFoo(barToFoo( jaxbElemToValue( bar) ) )
-
-
Method Detail
-
getImportTypes
public java.util.Set<Type> getImportTypes()
Description copied from class:ModelElementReturns a set containing thoseTypes referenced by this model element for which an import statement needs to be declared.- Specified by:
getImportTypesin interfaceAssignment- Specified by:
getImportTypesin classModelElement- Returns:
- A set with type referenced by this model element. Must not be
null.
-
getThrownTypes
public java.util.List<Type> getThrownTypes()
Description copied from interface:Assignmentreturns all types exception types thrown by this assignment.- Specified by:
getThrownTypesin interfaceAssignment- Returns:
- exceptions thrown
-
getOpenExpression
public java.lang.String getOpenExpression()
-
getCloseExpression
public java.lang.String getCloseExpression()
-
getAssignment
public Assignment getAssignment()
-
getSourceReference
public java.lang.String getSourceReference()
Description copied from interface:Assignmentthe source reference being a source-getter, a constant, nested method call, etc.- Specified by:
getSourceReferencein interfaceAssignment- Returns:
- source reference
-
isSourceReferenceParameter
public boolean isSourceReferenceParameter()
- Specified by:
isSourceReferenceParameterin interfaceAssignment- Returns:
- true when the source reference is the source parameter (and not a property of the source parameter type)
-
getSourcePresenceCheckerReference
public PresenceCheck getSourcePresenceCheckerReference()
Description copied from interface:Assignmentthe source presence checker reference- Specified by:
getSourcePresenceCheckerReferencein interfaceAssignment- Returns:
- source reference
-
getSourceType
public Type getSourceType()
Description copied from interface:Assignmentthe source type used in the matching process- Specified by:
getSourceTypein interfaceAssignment- Returns:
- source type (can be null)
-
createUniqueVarName
public java.lang.String createUniqueVarName(java.lang.String desiredName)
Description copied from interface:AssignmentCreates an unique safe (local) variable name.- Specified by:
createUniqueVarNamein interfaceAssignment- Parameters:
desiredName- the desired name- Returns:
- the desired name, made unique in the scope of the bean mapping.
-
getSourceLocalVarName
public java.lang.String getSourceLocalVarName()
Description copied from interface:Assignment- Specified by:
getSourceLocalVarNamein interfaceAssignment- Returns:
- local variable name (can be null if not set)
-
setSourceLocalVarName
public void setSourceLocalVarName(java.lang.String sourceLocalVarName)
Description copied from interface:AssignmentReplaces the sourceReference at the call site in the assignment in the template with this sourceLocalVarName. The sourceLocalVarName can subsequently be used for e.g. null checking.- Specified by:
setSourceLocalVarNamein interfaceAssignment- Parameters:
sourceLocalVarName- source local variable name
-
getSourceLoopVarName
public java.lang.String getSourceLoopVarName()
Description copied from interface:AssignmentSeeAssignment.getSourceLoopVarName()(java.lang.String) }- Specified by:
getSourceLoopVarNamein interfaceAssignment- Returns:
- loop variable (can be null if not set)
-
setSourceLoopVarName
public void setSourceLoopVarName(java.lang.String sourceLoopVarName)
Description copied from interface:AssignmentReplaces the sourceLocalVar or sourceReference at the call site in the assignment in the template with this sourceLoopVarName. The sourceLocalVar can subsequently be used for e.g. null checking.- Specified by:
setSourceLoopVarNamein interfaceAssignment- Parameters:
sourceLoopVarName- loop variable
-
getSourceParameterName
public java.lang.String getSourceParameterName()
Description copied from interface:AssignmentReturns the source parameter name, to which this assignment applies. Note: the source parameter itself might be mapped by this assignment, or one of its properties- Specified by:
getSourceParameterNamein interfaceAssignment- Returns:
- the source parameter name
-
setAssignment
public void setAssignment(Assignment assignment)
Description copied from interface:AssignmentAn assignment in itself can wrap another assignment. E.g.:- a MethodReference can wrap a TypeConversion, another MethodReference and ultimately a Simple
- a TypeConversion can wrap a MethodReference, and ultimately a Simple
- Specified by:
setAssignmentin interfaceAssignment- Parameters:
assignment- the assignment to set
-
getType
public Assignment.AssignmentType getType()
Description copied from interface:AssignmentReturns whether the type of assignment- Specified by:
getTypein interfaceAssignment- Returns:
Assignment.AssignmentType
-
isCallingUpdateMethod
public boolean isCallingUpdateMethod()
- Specified by:
isCallingUpdateMethodin interfaceAssignment
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-