IGNITE-1917: Refactoring: short, byte.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c905464f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c905464f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c905464f Branch: refs/heads/ignite-1917 Commit: c905464f2b6c3353d1c0cd1072450b72d348d2a0 Parents: 56ad7bd Author: vozerov-gridgain <voze...@gridgain.com> Authored: Wed Nov 18 16:36:50 2015 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Wed Nov 18 16:36:50 2015 +0300 ---------------------------------------------------------------------- .../internal/portable/BinaryReaderExImpl.java | 90 ++++++++------------ 1 file changed, 36 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c905464f/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 d232c7c..7460fd4 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 @@ -308,56 +308,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje * @return Value. * @throws BinaryObjectException If failed. */ - byte readByte(int fieldId) throws BinaryObjectException { - return findFieldById(fieldId) && checkFlag(BYTE) == Flag.NORMAL ? in.readByte() : 0; - } - - /** - * @param fieldId Field ID. - * @return Value. - * @throws BinaryObjectException In case of error. - */ - @Nullable Byte readByteNullable(int fieldId) throws BinaryObjectException { - if (findFieldById(fieldId)) { - if (checkFlag(BYTE) == Flag.NULL) - return null; - - return in.readByte(); - } - else - return null; - } - - /** - * @param fieldId Field ID. - * @return Value. - * @throws BinaryObjectException If failed. - */ - short readShort(int fieldId) throws BinaryObjectException { - return findFieldById(fieldId) && checkFlag(SHORT) == Flag.NORMAL ? in.readShort() : 0; - } - - /** - * @param fieldId Field ID. - * @return Value. - * @throws BinaryObjectException In case of error. - */ - @Nullable Short readShortNullable(int fieldId) throws BinaryObjectException { - if (findFieldById(fieldId)) { - if (checkFlag(SHORT) == Flag.NULL) - return null; - - return in.readShort(); - } - else - return null; - } - - /** - * @param fieldId Field ID. - * @return Value. - * @throws BinaryObjectException If failed. - */ long readLong(int fieldId) throws BinaryObjectException { return findFieldById(fieldId) && checkFlag(LONG) == Flag.NORMAL ? in.readLong() : 0; } @@ -995,9 +945,25 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje } /** {@inheritDoc} */ @Override public byte readByte(String fieldName) throws BinaryObjectException { - Byte val = readByteNullable(fieldId(fieldName)); + return findFieldByName(fieldName) && checkFlagPrimitive(BYTE) == Flag.NORMAL ? in.readByte() : 0; + } - return val != null ? val : 0; + /** + * @param fieldId Field ID. + * @return Value. + * @throws BinaryObjectException If failed. + */ + byte readByte(int fieldId) throws BinaryObjectException { + return findFieldById(fieldId) && checkFlagPrimitive(BYTE) == Flag.NORMAL ? in.readByte() : 0; + } + + /** + * @param fieldId Field ID. + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable Byte readByteNullable(int fieldId) throws BinaryObjectException { + return findFieldById(fieldId) && checkFlagPrimitive(BYTE) == Flag.NORMAL ? in.readByte() : null; } /** {@inheritDoc} */ @@ -1007,9 +973,25 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje /** {@inheritDoc} */ @Override public short readShort(String fieldName) throws BinaryObjectException { - Short val = readShortNullable(fieldId(fieldName)); + return findFieldByName(fieldName) && checkFlagPrimitive(SHORT) == Flag.NORMAL ? in.readShort() : 0; + } - return val != null ? val : 0; + /** + * @param fieldId Field ID. + * @return Value. + * @throws BinaryObjectException If failed. + */ + short readShort(int fieldId) throws BinaryObjectException { + return findFieldById(fieldId) && checkFlagPrimitive(SHORT) == Flag.NORMAL ? in.readShort() : 0; + } + + /** + * @param fieldId Field ID. + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable Short readShortNullable(int fieldId) throws BinaryObjectException { + return findFieldById(fieldId) && checkFlagPrimitive(SHORT) == Flag.NORMAL ? in.readShort() : null; } /** {@inheritDoc} */