001package org.unix4j.util; 002 003/** 004 * Utility class with static methods useful to implement {@code hashCode()} 005 * methods. 006 */ 007public class HashUtil { 008 009 /** 010 * Null-safe hash code method for objects. Returns the object hash code if 011 * it is not null, and 0 otherwise. 012 * 013 * @param o the object 014 * @return the object's hash code, or 0 if {@code o==null} 015 */ 016 public static int hashObject(Object o) { 017 return o == null ? 0 : o.hashCode(); 018 } 019 020 //no instances 021 private HashUtil() { 022 super(); 023 } 024}