litesoft
@ 600
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / shared / utils / ObjectUtils.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package com.temp.shared.utils; public class ObjectUtils { public static boolean areEqual( Object o1, Object o2 ) { return (o1 == o2) || ((o1 != null) && o1.equals( o2 )); } public static <T> T oneOfToStringIgnoreCase( String value, T... options ) { if ( (value != null) && (options != null) ) { for ( T option : options ) { if ( (option != null) && value.equalsIgnoreCase( option.toString() ) ) { return option; } } } return null; } @SuppressWarnings("unchecked") public static <T> T cast( Object object ) { return (T) object; } public static String simpleClassName( Object object ) { return simpleName( (object == null) ? null : object.getClass() ); } public static String simpleName( Class<?> klass ) { if ( klass == null ) { return null; } String name = "." + klass.getName() + "$"; name = name.substring( name.lastIndexOf( '.' ) ); return name.substring( 0, name.indexOf( '$' ) ); } } |