From 01c487d342714fea68a17682d3f7d00a974df865 Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Wed, 14 Aug 2013 21:43:09 +0200 Subject: [PATCH] #61 Moving method for assignment check to Type --- .../main/java/org/mapstruct/ap/model/Type.java | 15 +++++++++++++++ .../ap/processor/MethodRetrievalProcessor.java | 2 +- .../java/org/mapstruct/ap/util/TypeFactory.java | 16 ---------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/processor/src/main/java/org/mapstruct/ap/model/Type.java b/processor/src/main/java/org/mapstruct/ap/model/Type.java index 8ba814cd0..bcc2bd769 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/Type.java +++ b/processor/src/main/java/org/mapstruct/ap/model/Type.java @@ -148,6 +148,21 @@ public class Type extends AbstractModelElement implements Comparable { Collections.emptySet(); } + /** + * Whether this type is assignable to the given other type. + * + * @param other The other type. + * + * @return {@code true} if and only if this type is assignable to the given other type. + */ + public boolean isAssignableTo(Type other) { + if ( equals( other ) ) { + return true; + } + + return typeUtils.isAssignable( typeMirror, other.typeMirror ); + } + @Override public int hashCode() { final int prime = 31; diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java index 7cdfa39b0..ce93eb171 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java @@ -207,7 +207,7 @@ public class MethodRetrievalProcessor implements ModelElementProcessor