1 /* 2 * Copyright (C) 2007 ETH Zurich 3 * 4 * This file is part of Fosstrak (www.fosstrak.org). 5 * 6 * Fosstrak is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License version 2.1, as published by the Free Software Foundation. 9 * 10 * Fosstrak is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with Fosstrak; if not, write to the Free 17 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301 USA 19 */ 20 21 package org.fosstrak.epcis.repository; 22 23 /** 24 * Miscellaneous utility functions. 25 * 26 * @author Sean Wellington 27 */ 28 public class Utils { 29 30 /** 31 * @return <code>true</code> if both <code>o1</code> and <code>o2</code> 32 * are <code>null</code>; or <code>o1</code> and 33 * <code>o2</code> are both non-<code>null</code> and equal 34 * according to their <code>equals()</code> methods. 35 */ 36 public static final boolean eq(Object o1, Object o2) { 37 return (o1 == null && o2 == null) || (o1 != null && o2 != null && o1.equals(o2)); 38 } 39 40 /** 41 * @return <code>o.hashCode()</code> or <code>0</code> if <code>o</code> 42 * is <code>null</code>. 43 */ 44 public static final int hc(Object o) { 45 return o != null ? o.hashCode() : 0; 46 } 47 48 /** 49 * Hidden default constructor. 50 */ 51 private Utils() { 52 } 53 }