Changeset 6578 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2013-12-31T13:04:42+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6552 r6578 857 857 } 858 858 } 859 860 /** 861 * Cast an object savely. 862 * @param <T> the target type 863 * @param o the object to cast 864 * @param klass the target class (same as T) 865 * @return null if <code>o</code> is null or the type <code>o</code> is not 866 * a subclass of <code>klass</code>. The casted value otherwise. 867 */ 868 public static <T> T cast(Object o, Class<T> klass) { 869 if (klass.isInstance(o)) { 870 @SuppressWarnings("unchecked") 871 T ret = (T) o; 872 return ret; 873 } 874 return null; 875 } 876 859 877 }
Note:
See TracChangeset
for help on using the changeset viewer.