#513, source code naming consistence exceptionTypes == thrownTypes

This commit is contained in:
sjaakd 2015-05-17 11:35:24 +02:00
parent b4c514d479
commit b98644cfeb
18 changed files with 78 additions and 79 deletions

View File

@ -49,7 +49,7 @@ public class Direct extends ModelElement implements Assignment {
}
@Override
public List<Type> getExceptionTypes() {
public List<Type> getThrownTypes() {
return Collections.emptyList();
}

View File

@ -123,7 +123,7 @@ public class IterableMappingMethod extends MappingMethod {
else {
if ( method instanceof ForgedMethod ) {
ForgedMethod forgedMethod = (ForgedMethod) method;
forgedMethod.addThrownTypes( assignment.getExceptionTypes() );
forgedMethod.addThrownTypes( assignment.getThrownTypes() );
}
}
// target accessor is setter, so decorate assignment as setter

View File

@ -154,10 +154,10 @@ public class MapMappingMethod extends MappingMethod {
if ( method instanceof ForgedMethod ) {
ForgedMethod forgedMethod = (ForgedMethod) method;
if ( keyAssignment != null ) {
forgedMethod.addThrownTypes( keyAssignment.getExceptionTypes() );
forgedMethod.addThrownTypes( keyAssignment.getThrownTypes() );
}
if ( valueAssignment != null ) {
forgedMethod.addThrownTypes( valueAssignment.getExceptionTypes() );
forgedMethod.addThrownTypes( valueAssignment.getThrownTypes() );
}
}

View File

@ -41,7 +41,7 @@ public class MethodReference extends MappingMethod implements Assignment {
private final MapperReference declaringMapper;
private final Set<Type> importTypes;
private final List<Type> exceptionTypes;
private final List<Type> thrownTypes;
private final boolean isUpdateMethod;
/**
@ -78,7 +78,7 @@ public class MethodReference extends MappingMethod implements Assignment {
imported.add( targetType );
}
this.importTypes = Collections.<Type>unmodifiableSet( imported );
this.exceptionTypes = method.getThrownTypes();
this.thrownTypes = method.getThrownTypes();
this.isUpdateMethod = method.getMappingTargetParameter() != null;
}
@ -87,7 +87,7 @@ public class MethodReference extends MappingMethod implements Assignment {
this.declaringMapper = null;
this.contextParam = method.getContextParameter( contextParam );
this.importTypes = Collections.emptySet();
this.exceptionTypes = Collections.emptyList();
this.thrownTypes = Collections.emptyList();
this.isUpdateMethod = method.getMappingTargetParameter() != null;
}
@ -139,11 +139,11 @@ public class MethodReference extends MappingMethod implements Assignment {
}
@Override
public List<Type> getExceptionTypes() {
public List<Type> getThrownTypes() {
List<Type> exceptions = new ArrayList<Type>();
exceptions.addAll( exceptionTypes );
exceptions.addAll( thrownTypes );
if ( assignment != null ) {
exceptions.addAll( assignment.getExceptionTypes() );
exceptions.addAll( assignment.getThrownTypes() );
}
return exceptions;
}

View File

@ -36,7 +36,7 @@ public class TypeConversion extends ModelElement implements Assignment {
private static final String SOURCE_REFERENCE_PATTERN = "<SOURCE>";
private final Set<Type> importTypes;
private final List<Type> exceptionTypes;
private final List<Type> thrownTypes;
private final String openExpression;
private final String closeExpression;
@ -52,7 +52,7 @@ public class TypeConversion extends ModelElement implements Assignment {
String expression ) {
this.importTypes = new HashSet<Type>( importTypes );
this.importTypes.addAll( exceptionTypes );
this.exceptionTypes = exceptionTypes;
this.thrownTypes = exceptionTypes;
int patternIndex = expression.indexOf( SOURCE_REFERENCE_PATTERN );
this.openExpression = expression.substring( 0, patternIndex );
@ -65,8 +65,8 @@ public class TypeConversion extends ModelElement implements Assignment {
}
@Override
public List<Type> getExceptionTypes() {
return exceptionTypes;
public List<Type> getThrownTypes() {
return thrownTypes;
}
public String getOpenExpression() {

View File

@ -32,28 +32,28 @@ import org.mapstruct.ap.model.common.Type;
*/
public class AdderWrapper extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude;
private final List<Type> thrownTypesToExclude;
private final String sourceReference;
private final Type sourceType;
public AdderWrapper(
Assignment decoratedAssignment,
List<Type> exceptionTypesToExclude,
List<Type> thrownTypesToExclude,
String sourceReference,
Type sourceType) {
super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude;
this.thrownTypesToExclude = thrownTypesToExclude;
this.sourceReference = sourceReference;
this.sourceType = sourceType;
}
@Override
public List<Type> getExceptionTypes() {
List<Type> parentExceptionTypes = super.getExceptionTypes();
List<Type> result = new ArrayList<Type>( parentExceptionTypes );
for ( Type exceptionTypeToExclude : exceptionTypesToExclude ) {
for ( Type parentExceptionType : parentExceptionTypes ) {
if ( parentExceptionType.isAssignableTo( exceptionTypeToExclude ) ) {
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<Type>( parentThrownTypes );
for ( Type thrownTypeToExclude : thrownTypesToExclude ) {
for ( Type parentExceptionType : parentThrownTypes ) {
if ( parentExceptionType.isAssignableTo( thrownTypeToExclude ) ) {
result.remove( parentExceptionType );
}
}

View File

@ -57,7 +57,7 @@ public interface Assignment {
*
* @return exceptions thrown
*/
List<Type> getExceptionTypes();
List<Type> getThrownTypes();
/**
* An assignment in itself can wrap another assignment. E.g.:

View File

@ -42,8 +42,8 @@ public abstract class AssignmentWrapper extends ModelElement implements Assignme
}
@Override
public List<Type> getExceptionTypes() {
return decoratedAssignment.getExceptionTypes();
public List<Type> getThrownTypes() {
return decoratedAssignment.getThrownTypes();
}
@Override

View File

@ -42,28 +42,28 @@ import org.mapstruct.ap.util.Strings;
*/
public class GetterWrapperForCollectionsAndMaps extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude;
private final List<Type> thrownTypesToExclude;
private final Type localVarType;
private final String localVarName;
public GetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude,
public GetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> thrownTypesToExclude,
Type localVarType, Collection<String> existingVariableNames) {
super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude;
this.thrownTypesToExclude = thrownTypesToExclude;
this.localVarType = localVarType;
this.localVarName = Strings.getSaveVariableName( "target" + localVarType.getName(), existingVariableNames );
existingVariableNames.add( localVarName );
}
@Override
public List<Type> getExceptionTypes() {
List<Type> parentExceptionTypes = super.getExceptionTypes();
List<Type> result = new ArrayList<Type>( parentExceptionTypes );
for ( Type exceptionTypeToExclude : exceptionTypesToExclude ) {
for ( Type parentExceptionType : parentExceptionTypes ) {
if ( parentExceptionType.isAssignableTo( exceptionTypeToExclude ) ) {
result.remove( parentExceptionType );
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<Type>( parentThrownTypes );
for ( Type thrownTypeToExclude : thrownTypesToExclude ) {
for ( Type parentThrownType : parentThrownTypes ) {
if ( parentThrownType.isAssignableTo( thrownTypeToExclude ) ) {
result.remove( parentThrownType );
}
}
}

View File

@ -29,21 +29,21 @@ import org.mapstruct.ap.model.common.Type;
*/
public class LocalVarWrapper extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude;
private final List<Type> thrownTypesToExclude;
public LocalVarWrapper( Assignment decoratedAssignment, List<Type> exceptionTypesToExclude ) {
public LocalVarWrapper( Assignment decoratedAssignment, List<Type> thrownTypesToExclude ) {
super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude;
this.thrownTypesToExclude = thrownTypesToExclude;
}
@Override
public List<Type> getExceptionTypes() {
List<Type> parentExceptionTypes = super.getExceptionTypes();
List<Type> result = new ArrayList<Type>( parentExceptionTypes );
for ( Type exceptionTypeToExclude : exceptionTypesToExclude ) {
for ( Type parentExceptionType : parentExceptionTypes ) {
if ( parentExceptionType.isAssignableTo( exceptionTypeToExclude ) ) {
result.remove( parentExceptionType );
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<Type>( parentThrownTypes );
for ( Type thrownTypeToExclude : thrownTypesToExclude ) {
for ( Type parentThrownType : parentThrownTypes ) {
if ( parentThrownType.isAssignableTo( thrownTypeToExclude ) ) {
result.remove( parentThrownType );
}
}
}

View File

@ -29,21 +29,21 @@ import org.mapstruct.ap.model.common.Type;
*/
public class SetterWrapper extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude;
private final List<Type> thrownTypesToExclude;
public SetterWrapper( Assignment decoratedAssignment, List<Type> exceptionTypesToExclude ) {
public SetterWrapper( Assignment decoratedAssignment, List<Type> thrownTypesToExclude ) {
super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude;
this.thrownTypesToExclude = thrownTypesToExclude;
}
@Override
public List<Type> getExceptionTypes() {
List<Type> parentExceptionTypes = super.getExceptionTypes();
List<Type> result = new ArrayList<Type>( parentExceptionTypes );
for ( Type exceptionTypeToExclude : exceptionTypesToExclude ) {
for ( Type parentExceptionType : parentExceptionTypes ) {
if ( parentExceptionType.isAssignableTo( exceptionTypeToExclude ) ) {
result.remove( parentExceptionType );
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<Type>( parentThrownTypes );
for ( Type thrownTypeToExclude : thrownTypesToExclude ) {
for ( Type parentThrownType : parentThrownTypes ) {
if ( parentThrownType.isAssignableTo( thrownTypeToExclude ) ) {
result.remove( parentThrownType );
}
}
}

View File

@ -29,24 +29,23 @@ import org.mapstruct.ap.model.common.Type;
*/
public class UpdateWrapper extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude;
private final List<Type> thrownTypesToExclude;
private final Assignment factoryMethod;
public UpdateWrapper(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude,
Assignment factoryMethod ) {
public UpdateWrapper(Assignment decoratedAssignment, List<Type> thrownTypesToExclude, Assignment factoryMethod ) {
super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude;
this.thrownTypesToExclude = thrownTypesToExclude;
this.factoryMethod = factoryMethod;
}
@Override
public List<Type> getExceptionTypes() {
List<Type> parentExceptionTypes = super.getExceptionTypes();
List<Type> result = new ArrayList<Type>( parentExceptionTypes );
for ( Type exceptionTypeToExclude : exceptionTypesToExclude ) {
for ( Type parentExceptionType : parentExceptionTypes ) {
if ( parentExceptionType.isAssignableTo( exceptionTypeToExclude ) ) {
result.remove( parentExceptionType );
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<Type>( parentThrownTypes );
for ( Type thrownTypeToExclude : thrownTypesToExclude ) {
for ( Type parentThrownType : parentThrownTypes ) {
if ( parentThrownType.isAssignableTo( thrownTypeToExclude ) ) {
result.remove( parentThrownType );
}
}
}

View File

@ -18,7 +18,7 @@
limitations under the License.
-->
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
for ( <@includeModel object=sourceType/> ${iteratorReference} : ${sourceReference} ) {
${ext.targetBeanName}.${ext.targetWriteAccessorName}( <@includeModel object=assignment
targetBeanName=ext.targetBeanName
@ -38,7 +38,7 @@
targetType=ext.targetType/> );
}
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}

View File

@ -18,7 +18,7 @@
limitations under the License.
-->
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
<@includeModel object=ext.targetType/> ${localVarName} = <@_assignment/>;
${ext.targetBeanName}.${ext.targetWriteAccessorName}( Arrays.copyOf( ${localVarName}, ${localVarName}.length ) );
<#else>
@ -26,7 +26,7 @@
<@includeModel object=ext.targetType/> ${localVarName} = <@_assignment/>;
${ext.targetBeanName}.${ext.targetWriteAccessorName}( Arrays.copyOf( ${localVarName}, ${localVarName}.length ) );
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}

View File

@ -22,13 +22,13 @@ if ( ${ext.targetBeanName}.${ext.targetWriteAccessorName}() != null ) {
<#if ext.existingInstanceMapping>
${ext.targetBeanName}.${ext.targetWriteAccessorName}().clear();
</#if>
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
<@_assignmentLine/>
<#else>
try {
<@_assignmentLine/>
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}

View File

@ -18,14 +18,14 @@
limitations under the License.
-->
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
<#if !ext.isTargetDefined?? ><@includeModel object=ext.targetType/></#if> ${ext.targetWriteAccessorName} = <@_assignment/>;
<#else>
<#if !ext.isTargetDefined?? ><@includeModel object=ext.targetType/> ${ext.targetWriteAccessorName};</#if>
try {
${ext.targetWriteAccessorName} = <@_assignment/>;
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}

View File

@ -18,13 +18,13 @@
limitations under the License.
-->
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
${ext.targetBeanName}.${ext.targetWriteAccessorName}( <@_assignment/> );
<#else>
try {
${ext.targetBeanName}.${ext.targetWriteAccessorName}( <@_assignment/> );
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}

View File

@ -18,13 +18,13 @@
limitations under the License.
-->
<#if (exceptionTypes?size == 0) >
<#if (thrownTypes?size == 0) >
<@_assignment/>;
<#else>
try {
<@_assignment/>;
}
<#list exceptionTypes as exceptionType>
<#list thrownTypes as exceptionType>
catch ( <@includeModel object=exceptionType/> e ) {
throw new RuntimeException( e );
}