dota17 commented on a change in pull request #160:
URL: 
https://github.com/apache/commons-collections/pull/160#discussion_r424856068



##########
File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/Hasher.java
##########
@@ -103,6 +108,95 @@ default Builder withUnencoded(CharSequence item) {
             }
             return with(bytes);
         }
+
+        /**
+         * Adds an integer into the hasher.  The integer is converted into 4 
bytes
+         * through the use of ByteBuffer.putInt.
+         * @param data the integer to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putInt
+         */
+        default B with(int data) {
+            return with( ByteBuffer.allocate(Integer.BYTES).putInt( data 
).array());
+        }
+
+        /**
+         * Adds a long into the hasher.  The long is converted into 8 bytes
+         * through the use of ByteBuffer.putLong.
+         * @param data the long to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putLong
+         */
+        default B with(long data) {
+            return with( ByteBuffer.allocate(Long.BYTES).putLong( data 
).array());
+        }
+
+        /**
+         * Adds a double into the hasher.  The double is converted into 8 bytes
+         * through the use of ByteBuffer.putDouble.
+         * @param data the double to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putDouble
+         */
+        default B with(double data) {
+            return with( ByteBuffer.allocate(Double.BYTES).putDouble( data 
).array());
+        }
+
+        /**
+         * Adds a float into the hasher.  The float is converted into 4 bytes
+         * through the use of ByteBuffer.putFloat.
+         * @param data the float to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putFloat
+         */
+        default B with(float data) {
+            return with( ByteBuffer.allocate(Float.BYTES).putFloat( data 
).array());
+        }
+
+        /**
+         * Adds a char into the hasher.  The char is converted into 2 bytes
+         * through the use of ByteBuffer.putChar.
+         * @param data the char to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putChar
+         */
+        default  B with(char data) {
+            return with( ByteBuffer.allocate(Character.BYTES).putChar( data 
).array());
+        }
+
+        /**
+         * Adds a short into the hasher.  The short is converted into 2 bytes
+         * through the use of ByteBuffer.putShort.
+         * @param data the short to add.
+         * @return a reference to this object
+         * @see ByteBuffer#putShort
+         */
+        default B with(short data) {
+            return with( ByteBuffer.allocate(Short.BYTES).putShort( data 
).array());
+        }
+
+        /**
+         * Adds a BigInteger into the hasher.
+         * @param data the BigInteger to add.
+         * @return a reference to this object
+         */
+        default B with(BigInteger data) {
+            return with( data.toByteArray() );
+        }
+
+        /**
+         * Adds a BigDecimal into the hasher.
+         * The scale of the BigDecimal is placed in the buffer followed by the
+         * byte array for the unscaled value.
+         * @param data the BigDecimal to add.
+         * @return a reference to this object
+         */
+        default B with(BigDecimal data) {
+            byte[] value = data.unscaledValue().toByteArray();
+            return with( ByteBuffer.allocate( Integer.BYTES+value.length )

Review comment:
       return with( ByteBuffer.allocate( Integer.BYTES + value.length )




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to