/** * @see ChecksumProvider#checksumAsBytes() */ public byte[] checksumAsBytes() { this.hashBytes = Optional.of(this.pickChecksum().asBytes()); return this.hashBytes.get(); }
/** * @see ChecksumProvider#putBytes(byte[]) */ public ChecksumProvider putBytes(byte[] byteArray) { return this.putBytes(byteArray, 0, byteArray.length); }
/** * @see ChecksumProvider#putBytes(byte[], int, int) */ public ChecksumProvider putBytes(byte[] byteArray, int offset, int length) { this.verifyState(this.hashBytes, this.hashString); this.hasher.putBytes(byteArray, offset, length); return this; }
/** * @see ChecksumProvider#putBytes(ByteBuffer) */ public ChecksumProvider putBytes(ByteBuffer byteBuffer) { this.verifyState(this.hashBytes, this.hashString); if (byteBuffer.hasArray()) { this.hasher.putBytes(byteBuffer.array(), 0, byteBuffer.limit()); return this; } else { throw new IllegalArgumentException("Supplied ByteBuffer has " + "inaccessible array."); } }
/** * @see ChecksumProvider#putFile(String) */ public ChecksumProvider putFile(String filePath) { this.verifyState(this.hashBytes, this.hashString); try { this.hashCode = Optional.of( Files.hash(new File(filePath), this.hashFunction)); return this; } catch (IOException io) { throw new RuntimeException(io); } }
/** * @see ChecksumProvider#checksumAsString() */ public String checksumAsString() { this.hashString = Optional.of(this.pickChecksum().toString()); return this.hashString.get(); }