diff --git a/src/main/java/com/samskivert/util/ObserverList.java b/src/main/java/com/samskivert/util/ObserverList.java index fb35b237..10de6da7 100644 --- a/src/main/java/com/samskivert/util/ObserverList.java +++ b/src/main/java/com/samskivert/util/ObserverList.java @@ -121,10 +121,10 @@ public abstract class ObserverList }; /** @deprecated Use {@link Policy.SAFE_IN_ORDER}. */ - @Deprecated public static final Policy SAFE_IN_ORDER_NOTIFY = Policy.SAFE_IN_ORDER; + @Deprecated public static final int SAFE_IN_ORDER_NOTIFY = 1; /** @deprecated Use {@link Policy.FAST_UNSAFE}. */ - @Deprecated public static final Policy FAST_UNSAFE_NOTIFY = Policy.FAST_UNSAFE; + @Deprecated public static final int FAST_UNSAFE_NOTIFY = 2; /** * A convenience method for creating an observer list that avoids duplicating the type @@ -153,6 +153,16 @@ public abstract class ObserverList return new Impl(notifyPolicy, allowDups); } + /** @deprecated Switch to {@link Policy} constants. */ + @Deprecated public static ObserverList newList (int notifyPolicy, boolean allowDups) + { + switch (notifyPolicy) { + case SAFE_IN_ORDER_NOTIFY: return newList(Policy.SAFE_IN_ORDER, allowDups); + case FAST_UNSAFE_NOTIFY: return newList(Policy.FAST_UNSAFE, allowDups); + default: throw new IllegalArgumentException("Unknown policy " + notifyPolicy); + } + } + /** * Adds an observer at the specified index. * @return true if the observer was added, false if it was already in the list. @@ -187,6 +197,14 @@ public abstract class ObserverList */ public abstract void clear (); + /** + * Returns true if this list has no observers, false otherwise. + */ + public boolean isEmpty () + { + return size() == 0; + } + protected static class Impl extends ObserverList { protected Impl (Policy notifyPolicy, boolean allowDups) { _policy = notifyPolicy;