List of usage examples for com.google.common.hash Hasher putShort
@Override
Hasher putShort(short s);
From source file:nextflow.util.CacheHelper.java
public static Hasher hasher(Hasher hasher, Object value, HashMode mode) { if (value == null) return hasher; if (value instanceof Boolean) return hasher.putBoolean((Boolean) value); if (value instanceof Short) return hasher.putShort((Short) value); if (value instanceof Integer) return hasher.putInt((Integer) value); if (value instanceof Long) return hasher.putLong((Long) value); if (value instanceof Float) return hasher.putFloat((Float) value); if (value instanceof Double) return hasher.putDouble((Double) value); if (value instanceof Number) // reduce all other number types (BigInteger, BigDecimal, AtomicXxx, etc) to string equivalent return hasher.putUnencodedChars(value.toString()); if (value instanceof Character) return hasher.putChar((Character) value); if (value instanceof CharSequence) return hasher.putUnencodedChars((CharSequence) value); if (value instanceof Byte) return hasher.putByte((Byte) value); if (value instanceof byte[]) return hasher.putBytes((byte[]) value); if (value instanceof Object[]) { for (Object item : ((Object[]) value)) hasher = CacheHelper.hasher(hasher, item, mode); return hasher; }//from ww w . ja v a 2 s . com if (value instanceof Map) { // note: should map be order invariant as Set ? for (Object item : ((Map) value).values()) hasher = CacheHelper.hasher(hasher, item, mode); return hasher; } if (value instanceof Bag || value instanceof Set) return hashUnorderedCollection(hasher, (Collection) value, mode); if (value instanceof Collection) { for (Object item : ((Collection) value)) hasher = CacheHelper.hasher(hasher, item, mode); return hasher; } if (value instanceof FileHolder) return CacheHelper.hasher(hasher, ((FileHolder) value).getSourceObj(), mode); if (value instanceof Path) return hashFile(hasher, (Path) value, mode); if (value instanceof java.io.File) return hashFile(hasher, (java.io.File) value, mode); if (value instanceof UUID) { UUID uuid = (UUID) value; return hasher.putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()); } log.debug("[WARN] Unknown hashing type: {} -- {}", value.getClass(), value); return hasher.putInt(value.hashCode()); }
From source file:org.danilopianini.lang.HashUtils.java
private static void populateHasher(final Object data, final Hasher h) { if (data != null) { if (data instanceof Number) { final Number d = (Number) data; if (data instanceof Integer) { h.putInt(d.intValue());//w w w .ja va 2s . c o m } else if (data instanceof Double) { h.putDouble(d.doubleValue()); } else if (data instanceof Long) { h.putLong(d.longValue()); } else if (data instanceof Float) { h.putFloat(d.floatValue()); } else if (data instanceof Byte) { h.putByte(d.byteValue()); } else if (data instanceof Short) { h.putShort(d.shortValue()); } else { h.putInt(data.hashCode()); } } else if (data instanceof CharSequence) { h.putString((CharSequence) data, CHARSET); } else if (data.getClass().isArray()) { final int size = Array.getLength(data); for (int i = 0; i < size; i++) { populateHasher(Array.get(data, i), h); } } else if (data instanceof Iterable) { for (final Object o : (Iterable<?>) data) { populateHasher(o, h); } } else { h.putInt(data.hashCode()); } } }
From source file:com.facebook.buck.util.hash.AppendingHasher.java
@Override public Hasher putShort(short s) { for (Hasher hasher : hashers) { hasher.putShort(s); }/* www . j a v a 2s. c om*/ return this; }