ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivasilin...@apache.org
Subject [20/23] incubator-ignite git commit: #ignite-964: JSONCacheObject code style.
Date Wed, 01 Jul 2015 10:02:53 GMT
#ignite-964: JSONCacheObject code style.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bb412c42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bb412c42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bb412c42

Branch: refs/heads/ignite-964-1
Commit: bb412c4233c29a14fb96a58fb3cda2e0ea528388
Parents: d85dab7
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Wed Jul 1 12:36:54 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Wed Jul 1 12:36:54 2015 +0300

----------------------------------------------------------------------
 .../protocols/http/jetty/JSONCacheObject.java   | 78 +++++++++++---------
 1 file changed, 45 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb412c42/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/JSONCacheObject.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/JSONCacheObject.java
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/JSONCacheObject.java
index 67f2430..7ea30b3 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/JSONCacheObject.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/JSONCacheObject.java
@@ -26,28 +26,62 @@ import java.util.*;
  */
 public class JSONCacheObject {
     /** Fields map. */
-    private Map<Object, Object> fields = new HashMap<>();
+    private final Map<Object, Object> fields = new HashMap<>();
 
-    public JSONCacheObject() {
+    /**
+     * Empty constructor.
+     */
+    private JSONCacheObject() {
+    }
 
+    /**
+     * @param o JSON object.
+     */
+    public JSONCacheObject(JSONObject o) {
+        for (Object key : o.keySet())
+            addField(toSimpleObject(key), toSimpleObject(o.get(key)));
     }
 
-    public void setFields(Map<Object, Object> fields) {
-        this.fields = fields;
+    /**
+     * @param key Field name.
+     * @param val Field value.
+     */
+    public void addField(Object key, Object val) {
+        fields.put(key, val);
     }
 
-    public Map<Object, Object> getFields() {
-        return fields;
+    /**
+     * @param key Field name.
+     * @return Field value.
+     */
+    public Object getField(Object key) {
+        return fields.get(key);
     }
 
-    public JSONCacheObject(JSONObject o) {
-        for (Object key : o.keySet())
-            addField(toSimpleObject(key), toSimpleObject(o.get(key)));
+    /**
+     * @return Fields key set.
+     */
+    public Set<Object> keys() {
+        return fields.keySet();
+    }
+
+    /**
+     * @return Fields map.
+     */
+    public Map<Object, Object> getFields() {
+        return fields;
     }
 
+    /**
+     * Convert JSON object to JSONCacheObject
+     *
+     * @param o Object to convert.
+     * @return Converted object.
+     */
     private Object toSimpleObject(Object o) {
         if (o instanceof JSONObject) {
             JSONObject o1 = (JSONObject)o;
+
             JSONCacheObject res = new JSONCacheObject();
 
             for (Object key : o1.keySet())
@@ -57,7 +91,9 @@ public class JSONCacheObject {
         }
         else if (o instanceof JSONArray) {
             JSONArray o1 = (JSONArray) o;
+
             List<Object> val = new ArrayList<>();
+
             for (Object v : o1)
                 val.add(toSimpleObject(v));
 
@@ -67,32 +103,8 @@ public class JSONCacheObject {
         return o;
     }
 
-    /**
-     * @param key Field name.
-     * @param val Field value.
-     */
-    public void addField(Object key, Object val) {
-        fields.put(key, val);
-    }
-
-    /**
-     * @param key Field name.
-     * @return Field value.
-     */
-    public Object getField(Object key) {
-        return fields.get(key);
-    }
-
-    /**
-     * @return Fields key set.
-     */
-    public Set<Object> keys() {
-        return fields.keySet();
-    }
-
     /** {@inheritDoc} */
     @Override public int hashCode() {
-        //TODO:
         return fields.hashCode();
     }
 


Mime
View raw message