1 23 package com.sun.appserv.management.util.misc; 24 25 28 29 public final class ObjectUtil 30 { 31 private 32 ObjectUtil( ) 33 { 34 } 36 37 38 public static int 39 hashCode( final boolean value ) 40 { 41 return value ? 1 : 0; 42 } 43 44 public static int 45 hashCode( final Object ... items ) 46 { 47 int result = 0; 48 49 for( final Object item : items ) 50 { 51 result ^= hashCode( item ); 52 } 53 return result; 54 } 55 56 public static int 57 hashCode( final Object o ) 58 { 59 return o == null ? 0 : o.hashCode(); 60 } 61 62 public static int 63 hashCode( final long value ) 64 { 65 return (int)value ^ (int)(value >> 32); 66 } 67 68 public static int 69 hashCode( final double value ) 70 { 71 return new Double ( value ).hashCode(); 72 } 73 74 public static boolean 75 equals( final Object s1, final Object s2 ) 76 { 77 boolean equals = false; 78 79 if ( s1 == s2 ) 80 { 81 equals = true; 82 } 83 else if ( s1 != null ) 84 { 85 equals = s1.equals( s2 ); 86 } 87 else 88 { 89 equals = false; 91 } 92 93 return equals; 94 } 95 } 96 97 | Popular Tags |