Class NewInstanceCreation
java.lang.Object
org.mapstruct.ap.internal.writer.FreeMarkerWritable
org.mapstruct.ap.internal.model.common.ModelElement
org.mapstruct.ap.internal.model.common.NewInstanceCreation
- All Implemented Interfaces:
Writable
Model element representing the head of a
new T<>(...) expression. It always renders the diamond
operator for generic types, leaving any type-argument inference to the surrounding Java context.
The caller is responsible for emitting the parenthesised argument list after the model.
Imports contributed by this element only include the raw constructor type, not its type parameters: the generated source never references the parameter classes through this expression, so they are not needed here. If the surrounding code references a type parameter elsewhere (e.g. in a variable declaration or a method signature), that reference contributes its own imports through its own model element.
- Author:
- Filip Hrisafov
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.mapstruct.ap.internal.writer.Writable
Writable.Context -
Method Summary
Modifier and TypeMethodDescriptionstatic NewInstanceCreationCreates aNewInstanceCreationfor the given target type.Returns a set containing thoseTypes referenced by this model element for which an import statement needs to be declared.getType()booleanMethods inherited from class org.mapstruct.ap.internal.writer.FreeMarkerWritable
getTemplateName, getTemplateNameForClass, write
-
Method Details
-
forType
Creates aNewInstanceCreationfor the given target type. If the target has an implementation type (e.g.Collection->ArrayList), the implementation type is used.- Parameters:
targetType- the target type to be instantiated; must not benull- Returns:
- a new model
-
getType
-
getRawType
-
isGeneric
public boolean isGeneric() -
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 classModelElement- Returns:
- A set with type referenced by this model element. Must not be
null.
-