@@ -37,8 +37,20 @@ private Disposables() {
3737 * executed exactly once when the Disposable is disposed.
3838 * @param run the Runnable to wrap
3939 * @return the new Disposable instance
40+ * @deprecated use {@link #fromRunnable(Runnable)} to avoid lambda-ambiguity
4041 */
42+ @ Deprecated
4143 public static Disposable from (Runnable run ) {
44+ return fromRunnable (run );
45+ }
46+
47+ /**
48+ * Construct a Disposable by wrapping a Runnable that is
49+ * executed exactly once when the Disposable is disposed.
50+ * @param run the Runnable to wrap
51+ * @return the new Disposable instance
52+ */
53+ public static Disposable fromRunnable (Runnable run ) {
4254 ObjectHelper .requireNonNull (run , "run is null" );
4355 return new RunnableDisposable (run );
4456 }
@@ -48,8 +60,20 @@ public static Disposable from(Runnable run) {
4860 * executed exactly once when the Disposable is disposed.
4961 * @param run the Action to wrap
5062 * @return the new Disposable instance
63+ * @deprecated use {@link #fromRunnable(Runnable)} to avoid lambda-ambiguity
5164 */
65+ @ Deprecated
5266 public static Disposable from (Action run ) {
67+ return fromAction (run );
68+ }
69+
70+ /**
71+ * Construct a Disposable by wrapping a Action that is
72+ * executed exactly once when the Disposable is disposed.
73+ * @param run the Action to wrap
74+ * @return the new Disposable instance
75+ */
76+ public static Disposable fromAction (Action run ) {
5377 ObjectHelper .requireNonNull (run , "run is null" );
5478 return new ActionDisposable (run );
5579 }
@@ -59,10 +83,11 @@ public static Disposable from(Action run) {
5983 * cancelled exactly once when the Disposable is disposed.
6084 * @param future the Future to wrap
6185 * @return the new Disposable instance
86+ * @deprecated use {@link #fromRunnable(Runnable)} to avoid lambda-ambiguity
6287 */
88+ @ Deprecated
6389 public static Disposable from (Future <?> future ) {
64- ObjectHelper .requireNonNull (future , "future is null" );
65- return from (future , true );
90+ return fromFuture (future , true );
6691 }
6792
6893 /**
@@ -71,8 +96,32 @@ public static Disposable from(Future<?> future) {
7196 * @param future the Runnable to wrap
7297 * @param allowInterrupt if true, the future cancel happens via Future.cancel(true)
7398 * @return the new Disposable instance
99+ * @deprecated use {@link #fromRunnable(Runnable)} to avoid lambda-ambiguity
74100 */
101+ @ Deprecated
75102 public static Disposable from (Future <?> future , boolean allowInterrupt ) {
103+ return fromFuture (future , allowInterrupt );
104+ }
105+
106+ /**
107+ * Construct a Disposable by wrapping a Future that is
108+ * cancelled exactly once when the Disposable is disposed.
109+ * @param future the Future to wrap
110+ * @return the new Disposable instance
111+ */
112+ public static Disposable fromFuture (Future <?> future ) {
113+ ObjectHelper .requireNonNull (future , "future is null" );
114+ return fromFuture (future , true );
115+ }
116+
117+ /**
118+ * Construct a Disposable by wrapping a Runnable that is
119+ * executed exactly once when the Disposable is disposed.
120+ * @param future the Runnable to wrap
121+ * @param allowInterrupt if true, the future cancel happens via Future.cancel(true)
122+ * @return the new Disposable instance
123+ */
124+ public static Disposable fromFuture (Future <?> future , boolean allowInterrupt ) {
76125 ObjectHelper .requireNonNull (future , "future is null" );
77126 return new FutureDisposable (future , allowInterrupt );
78127 }
@@ -82,8 +131,20 @@ public static Disposable from(Future<?> future, boolean allowInterrupt) {
82131 * cancelled exactly once when the Disposable is disposed.
83132 * @param subscription the Runnable to wrap
84133 * @return the new Disposable instance
134+ * @deprecated use {@link #fromRunnable(Runnable)} to avoid lambda-ambiguity
85135 */
136+ @ Deprecated
86137 public static Disposable from (Subscription subscription ) {
138+ return fromSubscription (subscription );
139+ }
140+
141+ /**
142+ * Construct a Disposable by wrapping a Subscription that is
143+ * cancelled exactly once when the Disposable is disposed.
144+ * @param subscription the Runnable to wrap
145+ * @return the new Disposable instance
146+ */
147+ public static Disposable fromSubscription (Subscription subscription ) {
87148 ObjectHelper .requireNonNull (subscription , "subscription is null" );
88149 return new SubscriptionDisposable (subscription );
89150 }
@@ -93,7 +154,7 @@ public static Disposable from(Subscription subscription) {
93154 * @return a new, non-disposed Disposable instance
94155 */
95156 public static Disposable empty () {
96- return from (Functions .EMPTY_RUNNABLE );
157+ return fromRunnable (Functions .EMPTY_RUNNABLE );
97158 }
98159
99160 /**
0 commit comments