This is an automated email from the ASF dual-hosted git repository.

geertjan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 1be4a5d  Enable creation using methods with Map parameter (#483)
1be4a5d is described below

commit 1be4a5d4b7de09e535b5bb3392517d6a7654de53
Author: Svatopluk Dedic <svatopluk.de...@oracle.com>
AuthorDate: Wed Apr 4 22:09:28 2018 +0200

    Enable creation using methods with Map parameter (#483)
---
 .../src/org/openide/filesystems/annotations/LayerBuilder.java     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java 
b/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java
index bd79bf1..1b8235c 100644
--- 
a/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java
+++ 
b/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java
@@ -42,6 +42,7 @@ import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.Modifier;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.ElementFilter;
 import javax.tools.Diagnostic.Kind;
@@ -264,7 +265,12 @@ public final class LayerBuilder {
                 if 
(!originatingElement.getModifiers().contains(Modifier.STATIC)) {
                     throw new LayerGenerationException(clazz + "." + method + 
" must be static", originatingElement, processingEnv, annotation, 
annotationMethod);
                 }
-                if (!((ExecutableElement) 
originatingElement).getParameters().isEmpty()) {
+                List<? extends VariableElement> params = ((ExecutableElement) 
originatingElement).getParameters();
+                TypeMirror utilMapType = 
processingEnv.getTypeUtils().getDeclaredType(
+                        
processingEnv.getElementUtils().getTypeElement("java.util.Map"));
+                boolean mapParam = (params.size() == 1 && 
processingEnv.getTypeUtils().isAssignable(
+                        params.get(0).asType(), utilMapType));
+                if (!params.isEmpty() && !mapParam) {
                     throw new LayerGenerationException(clazz + "." + method + 
" must not take arguments", originatingElement, processingEnv, annotation, 
annotationMethod);
                 }
                 if (typeMirror != null && 
!processingEnv.getTypeUtils().isAssignable(((ExecutableElement) 
originatingElement).getReturnType(), typeMirror)) {

-- 
To stop receiving notification emails like this one, please contact
geert...@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to