camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhira...@apache.org
Subject [14/35] git commit: Added argument name and type uniqueness check
Date Tue, 10 Jun 2014 19:51:42 GMT
Added argument name and type uniqueness check


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/32677ffe
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/32677ffe
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/32677ffe

Branch: refs/heads/master
Commit: 32677ffe8291c698b7caa745212a765048a64de4
Parents: ec5a57e
Author: Dhiraj Bokde <dhirajsb@yahoo.com>
Authored: Wed May 28 14:20:13 2014 -0700
Committer: Dhiraj Bokde <dhirajsb@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodParser.java   | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/32677ffe/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index 0e839df..933a0b9 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -124,8 +124,29 @@ public abstract class ApiMethodParser<T> {
             result.add(new ApiMethodModel(name, resultType, arguments, method));
         }
 
+        // allow derived classes to post process
         result = processResults(result);
 
+        // check that argument names have the same type across methods
+        Map<String, Class<?>> allArguments = new HashMap<String, Class<?>>();
+        for (ApiMethodModel model : result) {
+            for (Argument argument : model.getArguments()) {
+                String name = argument.getName();
+                Class<?> argClass = allArguments.get(name);
+                Class<?> type = argument.getType();
+                if (argClass == null) {
+                    allArguments.put(name, type);
+                } else {
+                    if (argClass != type) {
+                        throw new IllegalArgumentException("Argument [" + name +
+                                "] is used in multiple methods with different types " +
+                                argClass.getCanonicalName() + ", " + type.getCanonicalName());
+                    }
+                }
+            }
+        }
+        allArguments.clear();
+
         Collections.sort(result, new Comparator<ApiMethodModel>() {
             @Override
             public int compare(ApiMethodModel model1, ApiMethodModel model2) {


Mime
View raw message