Ignore:
Timestamp:
2017-08-14T14:42:13+02:00 (2 years ago)
Author:
bastiK
Message:

fixed #14524 - save imagery layer zoom level to session (if needed)

File:
1 edited

Legend:

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

    r12601 r12604  
    5151import java.util.concurrent.TimeUnit;
    5252import java.util.concurrent.atomic.AtomicLong;
     53import java.util.function.Consumer;
    5354import java.util.function.Function;
    5455import java.util.function.Predicate;
     
    675676                return new Iterator<B>() {
    676677
    677                     private Iterator<? extends A> it = c.iterator();
     678                    private final Iterator<? extends A> it = c.iterator();
    678679
    679680                    @Override
     
    17021703     * @param klass the class U
    17031704     * @return function converting an object to a singleton stream or null
     1705     * @since 12594
    17041706     */
    17051707    public static <T, U> Function<T, Stream<U>> castToStream(Class<U> klass) {
    17061708        return x -> klass.isInstance(x) ? Stream.of(klass.cast(x)) : null;
    17071709    }
     1710
     1711    /**
     1712     * Helper method to replace the "<code>instanceof</code>-check and cast" pattern.
     1713     * Checks if an object is instance of class T and performs an action if that
     1714     * is the case.
     1715     * Syntactic sugar to avoid typing the class name two times, when one time
     1716     * would suffice.
     1717     * @param <T> the type for the instanceof check and cast
     1718     * @param o the object to check and cast
     1719     * @param klass the class T
     1720     * @param consumer action to take when o is and instance of T
     1721     * @since 12604
     1722     */
     1723    public static <T> void instanceOfThen(Object o, Class<T> klass, Consumer<? super T> consumer) {
     1724        if (klass.isInstance(o)) {
     1725            consumer.accept((T) o);
     1726        }
     1727    }
    17081728}
Note: See TracChangeset for help on using the changeset viewer.