oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1524736 - /oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java
Date Thu, 19 Sep 2013 13:26:08 GMT
Author: simonetripodi
Date: Thu Sep 19 13:26:07 2013
New Revision: 1524736

URL: http://svn.apache.org/r1524736
Log:
trivial: improved toString() representation

Modified:
    oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java

Modified: oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java?rev=1524736&r1=1524735&r2=1524736&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java (original)
+++ oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java Thu Sep
19 13:26:07 2013
@@ -81,14 +81,21 @@ public abstract class JWTEntity {
 
         int counter = 0;
         for (Entry<String, Object> customField : customFields.entrySet()) {
-            if (counter++ > 0) {
-                formatter.format(", ");
-            }
+            Object value = customField.getValue();
+
+            if (value != null) {
+                if (counter++ > 0) {
+                    formatter.format(", ");
+                }
+
+                String pattern;
+                if (customField.getValue() instanceof Number) {
+                    pattern = "\"%s\": %s";
+                } else {
+                    pattern = "\"%s\": \"%s\"";
+                }
 
-            if (customField.getValue() instanceof Number) {
-                formatter.format("\"%s\": %s", customField.getKey(), customField.getValue());
-            } else {
-                formatter.format("\"%s\": \"%s\"", customField.getKey(), customField.getValue());
+                formatter.format(pattern, customField.getKey(), value);
             }
         }
 



Mime
View raw message