ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [3/3] ignite git commit: IGNITE-1917: Refactoring: maps.
Date Thu, 19 Nov 2015 08:43:34 GMT
IGNITE-1917: Refactoring: maps.


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

Branch: refs/heads/ignite-1917
Commit: 29762a291578af726478c037b2d10fa1d685526a
Parents: e42f745
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Nov 19 11:44:06 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Nov 19 11:44:06 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/BinaryReaderExImpl.java   | 66 +++++++++++---------
 1 file changed, 35 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/29762a29/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 0ba4790..35f0488 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -304,26 +304,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
 
     /**
      * @param fieldId Field ID.
-     * @param cls Map class.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
-    @Nullable Map<?, ?> readMap(int fieldId, @Nullable Class<? extends Map> cls)
-        throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            Flag flag = checkFlag(MAP);
-
-            if (flag == Flag.NORMAL)
-                return doReadMap(true, cls);
-            else if (flag == Flag.HANDLE)
-                return readHandleField();
-        }
-
-        return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
      * @return Value.
      * @throws BinaryObjectException On case of error.
      */
@@ -1286,30 +1266,54 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
 
     /** {@inheritDoc} */
     @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName) throws
BinaryObjectException {
-        return (Map<K, V>)readMap(fieldId(fieldName), null);
+        return findFieldByName(fieldName) ? (Map<K, V>)readMap0(null) : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException
{
-        if (checkFlag(MAP) == Flag.NULL)
-            return null;
+    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, Class<?
extends Map<K, V>> mapCls)
+        throws BinaryObjectException {
+        return findFieldByName(fieldName) ? readMap0(mapCls) : null;
+    }
 
-        return (Map<K, V>)doReadMap(true, null);
+    /**
+     * @param fieldId Field ID.
+     * @param mapCls Map class.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable Map<?, ?> readMap(int fieldId, @Nullable Class<? extends Map> mapCls)
throws BinaryObjectException {
+        return findFieldById(fieldId) ? readMap0(mapCls) : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, Class<?
extends Map<K, V>> mapCls)
-        throws BinaryObjectException {
-        return (Map<K, V>)readMap(fieldId(fieldName), mapCls);
+    @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException
{
+        return readMap0(null);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public <K, V> Map<K, V> readMap(Class<? extends Map<K,
V>> mapCls)
         throws BinaryObjectException {
-        if (checkFlag(MAP) == Flag.NULL)
-            return null;
+        return readMap0(mapCls);
+    }
 
-        return (Map<K, V>)doReadMap(true, mapCls);
+    /**
+     * Internal read map routine.
+     *
+     * @param cls Map class.
+     * @return Value.
+     * @throws BinaryObjectException If failed.
+     */
+    private Map readMap0(@Nullable Class<? extends Map> cls) throws BinaryObjectException
{
+        switch (checkFlag(MAP)) {
+            case NORMAL:
+                return (Map)doReadMap(true, cls);
+
+            case HANDLE:
+                return readHandleField();
+
+            default:
+                return null;
+        }
     }
 
     /**


Mime
View raw message