ignite-commits mailing list archives

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


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

Branch: refs/heads/ignite-1917
Commit: e42f745e4811070ed991a77eb75f09b947ddd714
Parents: ee15740
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Nov 19 11:37:28 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Nov 19 11:37:28 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/BinaryReaderExImpl.java   | 158 ++++++++++---------
 1 file changed, 82 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e42f745e/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 d57339f..0ba4790 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 Collection class.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
-    @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable Class<?
extends Collection> cls)
-        throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            Flag flag = checkFlag(COL);
-
-            if (flag == Flag.NORMAL)
-                return (Collection<T>)doReadCollection(true, cls);
-            else if (flag == Flag.HANDLE)
-                return readHandleField();
-        }
-
-        return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
      * @param cls Map class.
      * @return Value.
      * @throws BinaryObjectException In case of error.
@@ -1163,62 +1143,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection(String fieldName)
throws BinaryObjectException {
-        return readCollection(fieldId(fieldName), null);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection() throws BinaryObjectException
{
-        if (checkFlag(COL) == Flag.NULL)
-            return null;
-
-        return (Collection<T>)doReadCollection(true, null);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection(String fieldName,
-        Class<? extends Collection<T>> colCls) throws BinaryObjectException {
-        return readCollection(fieldId(fieldName), colCls);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection(Class<? extends
Collection<T>> colCls)
-        throws BinaryObjectException {
-        if (checkFlag(COL) == Flag.NULL)
-            return null;
-
-        return (Collection<T>)doReadCollection(true, colCls);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName) throws
BinaryObjectException {
-        return (Map<K, V>)readMap(fieldId(fieldName), null);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException
{
-        if (checkFlag(MAP) == Flag.NULL)
-            return null;
-
-        return (Map<K, V>)doReadMap(true, 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);
-    }
-
-    /** {@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 (Map<K, V>)doReadMap(true, mapCls);
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public <T extends Enum<?>> T readEnum(String fieldName)
throws BinaryObjectException {
         return findFieldByName(fieldName) ? (T)readEnum0(null) : null;
     }
@@ -1306,6 +1230,88 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
         }
     }
 
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> Collection<T> readCollection(String fieldName)
throws BinaryObjectException {
+        return findFieldByName(fieldName) ? (Collection<T>)readCollection0(null) :
null;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> Collection<T> readCollection(String fieldName,
+        Class<? extends Collection<T>> colCls) throws BinaryObjectException {
+        return findFieldByName(fieldName) ? readCollection0(colCls) : null;
+    }
+
+    /**
+     * @param fieldId Field ID.
+     * @param colCls Collection class.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable Class<?
extends Collection> colCls)
+        throws BinaryObjectException {
+        return findFieldById(fieldId) ? (Collection<T>)readCollection0(colCls) : null;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> Collection<T> readCollection() throws BinaryObjectException
{
+        return readCollection0(null);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> Collection<T> readCollection(Class<? extends
Collection<T>> colCls)
+        throws BinaryObjectException {
+        return readCollection0(colCls);
+    }
+
+    /**
+     * Internal read collection routine.
+     *
+     * @param cls Collection class.
+     * @return Value.
+     * @throws BinaryObjectException If failed.
+     */
+    private Collection readCollection0(@Nullable Class<? extends Collection> cls)
+        throws BinaryObjectException {
+        switch (checkFlag(COL)) {
+            case NORMAL:
+                return (Collection)doReadCollection(true, cls);
+
+            case HANDLE:
+                return readHandleField();
+
+            default:
+                return null;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName) throws
BinaryObjectException {
+        return (Map<K, V>)readMap(fieldId(fieldName), null);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException
{
+        if (checkFlag(MAP) == Flag.NULL)
+            return null;
+
+        return (Map<K, V>)doReadMap(true, 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);
+    }
+
+    /** {@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 (Map<K, V>)doReadMap(true, mapCls);
+    }
+
     /**
      * Ensure that type flag is either null, handle or contains expected value.
      *


Mime
View raw message