@@ -1002,7 +1002,7 @@ public int unsignedByteAt(int index) {
10021002 */
10031003 public char charAt (int index ) {
10041004 Util .checkIndexBounds (length (), index , 2 , "char" );
1005- return (( ByteBuffer ) ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ) ).getChar ();
1005+ return ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ).getChar ();
10061006 }
10071007
10081008 /**
@@ -1015,7 +1015,7 @@ public char charAt(int index) {
10151015 */
10161016 public short shortAt (int index ) {
10171017 Util .checkIndexBounds (length (), index , 2 , "short" );
1018- return (( ByteBuffer ) ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ) ).getShort ();
1018+ return ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ).getShort ();
10191019 }
10201020
10211021 /**
@@ -1028,7 +1028,7 @@ public short shortAt(int index) {
10281028 */
10291029 public int intAt (int index ) {
10301030 Util .checkIndexBounds (length (), index , 4 , "int" );
1031- return (( ByteBuffer ) ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ) ).getInt ();
1031+ return ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ).getInt ();
10321032 }
10331033
10341034 /**
@@ -1041,7 +1041,7 @@ public int intAt(int index) {
10411041 */
10421042 public long longAt (int index ) {
10431043 Util .checkIndexBounds (length (), index , 8 , "long" );
1044- return (( ByteBuffer ) ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ) ).getLong ();
1044+ return ByteBuffer .wrap (internalArray ()).order (byteOrder ).position (index ).getLong ();
10451045 }
10461046
10471047 /**
@@ -1478,6 +1478,12 @@ public int compareTo(Bytes o) {
14781478 return internalBuffer ().compareTo (o .internalBuffer ());
14791479 }
14801480
1481+ /**
1482+ * Checks if this instance is equal to given other instance o
1483+ *
1484+ * @param o other instance
1485+ * @return if the instance are equal
1486+ */
14811487 @ Override
14821488 public boolean equals (Object o ) {
14831489 if (this == o ) return true ;
@@ -1489,6 +1495,37 @@ public boolean equals(Object o) {
14891495 return byteOrder != null ? byteOrder .equals (bytes .byteOrder ) : bytes .byteOrder == null ;
14901496 }
14911497
1498+ /**
1499+ * Compares the inner array with given array
1500+ *
1501+ * @param anotherArray to compare with
1502+ * @return true if {@link Arrays#equals(byte[], byte[])} returns true on given and internal array
1503+ */
1504+ public boolean equals (byte [] anotherArray ) {
1505+ return anotherArray != null && Arrays .equals (internalArray (), anotherArray );
1506+ }
1507+
1508+ /**
1509+ * Compares the inner array with given array.
1510+ * Note: a <code>null</code> Byte will not be equal to a <code>0</code> byte
1511+ *
1512+ * @param anotherArray to compare with
1513+ * @return true if both array have same length and every byte element is the same
1514+ */
1515+ public boolean equals (Byte [] anotherArray ) {
1516+ return Util .equals (internalArray (), anotherArray );
1517+ }
1518+
1519+ /**
1520+ * Compares the inner array with the inner array of given ByteBuffer
1521+ *
1522+ * @param buffer to compare with
1523+ * @return true if both array have same length and every byte element is the same
1524+ */
1525+ public boolean equals (ByteBuffer buffer ) {
1526+ return buffer != null && Arrays .equals (internalArray (), buffer .array ());
1527+ }
1528+
14921529 /**
14931530 * Checks only for internal array content
14941531 *
0 commit comments