use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class MappingMethodOptions method applyIgnoreAll.
public void applyIgnoreAll(SourceMethod method, TypeFactory typeFactory, FormattingMessager messager) {
CollectionMappingStrategyGem cms = method.getOptions().getMapper().getCollectionMappingStrategy();
Type writeType = method.getResultType();
if (!method.isUpdateMethod()) {
writeType = typeFactory.effectiveResultTypeFor(writeType, method.getOptions().getBeanMapping().getBuilder());
}
Map<String, Accessor> writeAccessors = writeType.getPropertyWriteAccessors(cms);
for (MappingOptions mapping : mappings) {
String mappedTargetProperty = getFirstTargetPropertyName(mapping);
if (!".".equals(mappedTargetProperty)) {
// Remove the mapped target property from the write accessors
writeAccessors.remove(mappedTargetProperty);
} else {
messager.printMessage(method.getExecutable(), getBeanMapping().getMirror(), Message.BEANMAPPING_IGNORE_BY_DEFAULT_WITH_MAPPING_TARGET_THIS);
// Nothing more to do if this is reached
return;
}
}
// The writeAccessors now contains only the accessors that should be ignored
for (String targetPropertyName : writeAccessors.keySet()) {
MappingOptions mapping = MappingOptions.forIgnore(targetPropertyName);
mappings.add(mapping);
}
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class SourceReference method push.
public List<SourceReference> push(TypeFactory typeFactory, FormattingMessager messager, Method method) {
List<SourceReference> result = new ArrayList<>();
PropertyEntry deepestProperty = getDeepestProperty();
if (deepestProperty != null) {
Type type = deepestProperty.getType();
Map<String, ReadAccessor> newDeepestReadAccessors = type.getPropertyReadAccessors();
String parameterName = getParameter().getName();
String deepestPropertyFullName = deepestProperty.getFullName();
for (Map.Entry<String, ReadAccessor> newDeepestReadAccessorEntry : newDeepestReadAccessors.entrySet()) {
// Always include the parameter name in the new full name.
// Otherwise multi source parameters might be reported incorrectly
String newFullName = parameterName + "." + deepestPropertyFullName + "." + newDeepestReadAccessorEntry.getKey();
SourceReference sourceReference = new BuilderFromMapping().sourceName(newFullName).method(method).messager(messager).typeFactory(typeFactory).build();
result.add(sourceReference);
}
}
return result;
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class UpdateWrapper method getThrownTypes.
@Override
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<>(parentThrownTypes);
for (Type thrownTypeToExclude : thrownTypesToExclude) {
for (Type parentThrownType : parentThrownTypes) {
if (parentThrownType.isAssignableTo(thrownTypeToExclude)) {
result.remove(parentThrownType);
}
}
}
return result;
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class LocalVarWrapper method getThrownTypes.
@Override
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<>(parentThrownTypes);
for (Type thrownTypeToExclude : thrownTypesToExclude) {
for (Type parentThrownType : parentThrownTypes) {
if (parentThrownType.isAssignableTo(thrownTypeToExclude)) {
result.remove(parentThrownType);
}
}
}
return result;
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class WrapperForCollectionsAndMaps method getThrownTypes.
@Override
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<>(parentThrownTypes);
for (Type thrownTypeToExclude : thrownTypesToExclude) {
for (Type parentThrownType : parentThrownTypes) {
if (parentThrownType.isAssignableTo(thrownTypeToExclude)) {
result.remove(parentThrownType);
}
}
}
return result;
}
Aggregations