Class Hasher
- java.lang.Object
-
- org.apache.maven.plugins.enforcer.Hasher
-
public class Hasher extends java.lang.Object
Utility class to generate hashes/checksums for binary files. Typically used to generate a hashes for .class files to compare those files for equality.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
classFilePath
the path to the .class file.
-
Constructor Summary
Constructors Constructor Description Hasher(java.lang.String classFilePath)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
closeAll(java.io.Closeable... closeables)
java.lang.String
generateHash(org.apache.maven.artifact.Artifact artifact)
private java.lang.String
hashForFileInDirectory(java.io.File artifactFile)
private java.lang.String
hashForFileInJar(java.io.File artifactFile)
-
-
-
Method Detail
-
generateHash
public java.lang.String generateHash(org.apache.maven.artifact.Artifact artifact)
- Parameters:
artifact
- The artifact (example: jar file) which contains theclassFilePath
. We'll generate a hash for the class file inside this artifact.- Returns:
- generate a hash/checksum for the .class file in the provided artifact.
-
hashForFileInDirectory
private java.lang.String hashForFileInDirectory(java.io.File artifactFile) throws java.io.IOException
- Throws:
java.io.IOException
-
hashForFileInJar
private java.lang.String hashForFileInJar(java.io.File artifactFile) throws java.io.IOException
- Throws:
java.io.IOException
-
closeAll
private void closeAll(java.io.Closeable... closeables) throws java.io.IOException
- Throws:
java.io.IOException
-
-