Guava HashCode - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava HashCode class.

This code example shows how to use the following methods:asBytes
      return this; 
   } 
 
   public ContentMetadata build() { 
      return new BaseImmutableContentMetadata(contentType, contentLength, 
               contentMD5 == null ? null : contentMD5.asBytes(), contentDisposition, 
               contentLanguage, contentEncoding, expires); 
   } 
 
   public static ContentMetadataBuilder fromContentMetadata(ContentMetadata in) { 
      return new ContentMetadataBuilder().contentType(in.getContentType()).contentLength(in.getContentLength()) 
               .contentMD5(in.getContentMD5()).contentDisposition(in.getContentDisposition()).contentLanguage( 
                        in.getContentLanguage()).contentEncoding(in.getContentEncoding()).expires(in.getExpires()); 
   } 
 
   @Override 
   public int hashCode() { 
      return Objects.hashCode(contentDisposition, contentEncoding, contentLanguage, contentLength,  
               contentMD5, contentType, expires); 
   } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:toString
 
  @Override 
  protected RuleKey.Builder appendDetailsToRuleKey(RuleKey.Builder builder) {
    return builder
        .setReflectively("donwnload-at-runtime", isBuildTimeDownloadingOk)
        .setReflectively("sha1", sha1.toString())
        .setReflectively("out", output.toString())
        .setReflectively("url", uri.toString());
  } 
 
  @Override 
  public ImmutableList<Step> getBuildSteps(
      BuildContext context, BuildableContext buildableContext) {
    if (!isBuildTimeDownloadingOk) {
      throw new HumanReadableException( 
          "Downloading files at runtime is disabled, please run 'buck fetch' before your build"); 
    } 
 
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
   /** @deprecated use {@link #getContentMD5AsHashCode()} instead. */ 
   @Deprecated 
   @Override 
   public byte[] getContentMD5() { 
      HashCode hashCode = getContentMD5AsHashCode(); 
      return hashCode == null ? null : hashCode.asBytes(); 
   } 
 
   @Override 
   public HashCode getContentMD5AsHashCode() { 
      return contentMD5; 
   } 
 
   /** @deprecated use {@link #setContentMD5(HashCode)} instead. */ 
   @Deprecated 
   @Override 
   public void setContentMD5(byte[] md5) { 
      setContentMD5(md5 == null ? null : HashCode.fromBytes(md5)); 
   } 
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
   /** @deprecated use {@link #getContentMD5AsHashCode()} instead. */ 
   @Deprecated 
   @Override 
   public byte[] getContentMD5() { 
      HashCode hashCode = getContentMD5AsHashCode();
      return hashCode == null ? null : hashCode.asBytes();
   } 
 
   @Override 
   public HashCode getContentMD5AsHashCode() {
      return contentMD5;
   } 
 
   /** 
    * {@inheritDoc} 
    */ 
   @Override 
   public String getContentType() {
      return contentType;
   } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
   * @return 128 bits of hash result 
   */ 
  public byte[] hash(byte[] data) {
    HashCode hashCode = byteArrayHasher.hashBytes(data);
 
    return hashCode.asBytes();
  } 
 
  public long hashToLong(byte[] data) {
    HashCode hashCode = byteArrayHasher.hashBytes(data);
 
    return hashCode.asLong();
  } 
 
 
  /** 
   * A special version for long integers 
   * 
   * @param data the data to hash 
   * @return lower 64 bites of the 128-bit hash result. 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
      byte[] keyBlob = keyBlob(publicExponent, modulus);
      return hexColonDelimited(Hashing.md5().hashBytes(keyBlob));
   } 
 
   private static String hexColonDelimited(HashCode hc) {
      return on(':').join(fixedLength(2).split(base16().lowerCase().encode(hc.asBytes())));
   } 
 
   private static byte[] keyBlob(BigInteger publicExponent, BigInteger modulus) {
      try { 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         writeLengthFirst("ssh-rsa".getBytes(), out);
         writeLengthFirst(publicExponent.toByteArray(), out);
         writeLengthFirst(modulus.toByteArray(), out);
         return out.toByteArray();
      } catch (IOException e) {
         throw propagate(e);
      } 
   } 
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
	} 
 
	private byte[] sha1Digest(String text) {
		HashFunction hf = Hashing.sha1();
		HashCode hashCode = hf.hashString(text, Charsets.UTF_8);
		return hashCode.asBytes();
	} 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
 
    } 
 
    public static BlobData build(ByteSource src) throws IOException {
        HashCode hashCode = src.hash(Hashing.md5());
        ByteString hash = ByteString.copyFrom(hashCode.asBytes());
 
        return new BlobData(src, hash);
    } 
 
    public static BlobData build(File file) throws IOException {
        return build(Files.asByteSource(file));
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:asBytes
     * @return the {@code ObjectId} generated from the string 
     */ 
    public static ObjectId forString(final String strToHash) {
        Preconditions.checkNotNull(strToHash);
        HashCode hashCode = HASH_FUNCTION.hashString(strToHash, Charset.forName("UTF-8"));
        return new ObjectId(hashCode.asBytes(), false);
    } 
 
    /** 
     * Returns the value of this ObjectId's internal hash at the given index without having to go 
     * through {@link #getRawValue()} and hence create excessive defensive copies of the byte array. 
     *  
     * @param index the index of the byte inside this objectid's internal hash to return 
     * @return the byte at the given index as an integer 
     */ 
    public int byteN(int index) {
        int b = this.hashCode[index] & 0xFF;
        return b;
    } 
} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:equals
    @SqlType(MAP_BIGINT_DOUBLE)
    public static Block features(@SqlType(StandardTypes.DOUBLE) double f1, @SqlType(StandardTypes.DOUBLE) double f2, @SqlType(StandardTypes.DOUBLE) double f3, @SqlType(StandardTypes.DOUBLE) double f4, @SqlType(StandardTypes.DOUBLE) double f5, @SqlType(StandardTypes.DOUBLE) double f6)
    { 
        return featuresHelper(f1, f2, f3, f4, f5, f6);
    } 
 
    @ScalarFunction 
    @SqlType(MAP_BIGINT_DOUBLE)
    public static Block features(@SqlType(StandardTypes.DOUBLE) double f1, @SqlType(StandardTypes.DOUBLE) double f2, @SqlType(StandardTypes.DOUBLE) double f3, @SqlType(StandardTypes.DOUBLE) double f4, @SqlType(StandardTypes.DOUBLE) double f5, @SqlType(StandardTypes.DOUBLE) double f6, @SqlType(StandardTypes.DOUBLE) double f7)
    { 
        return featuresHelper(f1, f2, f3, f4, f5, f6, f7);
    } 
 
    @ScalarFunction 
    @SqlType(MAP_BIGINT_DOUBLE)
    public static Block features(@SqlType(StandardTypes.DOUBLE) double f1, @SqlType(StandardTypes.DOUBLE) double f2, @SqlType(StandardTypes.DOUBLE) double f3, @SqlType(StandardTypes.DOUBLE) double f4, @SqlType(StandardTypes.DOUBLE) double f5, @SqlType(StandardTypes.DOUBLE) double f6, @SqlType(StandardTypes.DOUBLE) double f7, @SqlType(StandardTypes.DOUBLE) double f8)
    { 
        return featuresHelper(f1, f2, f3, f4, f5, f6, f7, f8);
    } 
 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Guava HashCode Methods: