code: private HashState hashCompare(String location, File resource)
              throws ResourceDownloadError {
          String tmpPath = getSystemConfiguration().getCacheDirectory()
                  .getAbsolutePath();
  
          String remoteHashLocation = location + SHA256_EXTENSION;
  
          String tempHashPath = asPath(
                  ResourceType.TMP_FILE.getResourceFolderName(),
                  encodeLocation(location),
                  CacheLookupService.DEFAULT_RESOURCE_FILE_NAME
                          + SHA256_EXTENSION);
  
          // download resource hash
          File remoteHashFile = null;
          try {
              remoteHashFile = resolveResource(remoteHashLocation, tmpPath,
                      tempHashPath);
          } catch (ResourceDownloadError e) {
              return HashState.MISSING_REMOTE_HASH;
          }
  
          String absPath = resource.getAbsolutePath();
          File localHashFile = new File(absPath + SHA256_EXTENSION);
  
          if (!localHashFile.exists() || !localHashFile.canRead()) {
              localHashFile = createLocalHash(resource, location);
          }
  
          // compare hash files
          try {
              if (areHashFilesEqual(localHashFile, remoteHashFile, location)) {
                  // hashes are equal, so cached resource is the latest
                  // return cached resource
                  return HashState.HASH_MATCH;
              }
  
              // hashes are not equal
              return HashState.HASH_MISMATCH;
          } finally {
              // delete the downloaded temporary hash
              if (!remoteHashFile.delete()) {
                  remoteHashFile.deleteOnExit();
              }
          }
      }
docs: Compare hashes of the remote resource to the local resource. The
  comparison can result in the following:
  <ul>
  <li>If the resource's remote hash does not exist then return
  {@link HashState#MISSING_REMOTE_HASH}.</li>
  <li>If the resource's remote hash matches the local resource's hash then
  return {@link HashState#HASH_MATCH}</li>
  <li>If the resource's remote hash does not match the local resource's
  hash then return {@link HashState#HASH_MISMATCH}.</li>
  </ul>
  
  @param location {@link String}, the remote resource location
  @param resource {@link File}, the resource's local copy in the cache
  @return {@link HashState} the state of the hash comparison which is
  useful for deciding how to deal further with the resource
  @throws IOException Thrown if there was an IO error in handling hash
  files