Ignore:
Timestamp:
2013-12-31T13:04:42+01:00 (10 years ago)
Author:
bastiK
Message:

Preferences rework. Merges the 4 maps for the 4 setting
types into a single map. The code for the get...() and set...()
methods is also unified.
Additional consistency checks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6552 r6578  
    857857        }
    858858    }
     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
    859877}
Note: See TracChangeset for help on using the changeset viewer.