| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.internal.util; |
| 15 |
|
| 16 |
import java.util.*; |
| 17 |
|
| 18 |
import io.reactivex.rxjava3.functions.*; |
| 19 |
|
| 20 |
public final class TestingHelper { |
| 21 |
|
| 22 |
private TestingHelper() { |
| 23 |
// prevent instantiation |
| 24 |
} |
| 25 |
|
| 26 |
public static <T> Consumer<T> addToList(final List<T> list) { |
| 27 |
return new Consumer<T>() { |
| 28 |
|
| 29 |
@Override |
| 30 |
public void accept(T t) { |
| 31 |
list.add(t); |
| 32 |
} |
| 33 |
}; |
| 34 |
} |
| 35 |
|
| 36 |
public static <T> Supplier<List<T>> supplierListCreator() { |
| 37 |
return new Supplier<List<T>>() { |
| 38 |
|
| 39 |
@Override |
| 40 |
public List<T> get() { |
| 41 |
return new ArrayList<>(); |
| 42 |
} |
| 43 |
}; |
| 44 |
} |
| 45 |
|
| 46 |
public static BiConsumer<Object, Object> biConsumerThrows(final RuntimeException e) { |
| 47 |
return new BiConsumer<Object, Object>() { |
| 48 |
|
| 49 |
@Override |
| 50 |
public void accept(Object t1, Object t2) { |
| 51 |
throw e; |
| 52 |
} |
| 53 |
}; |
| 54 |
} |
| 55 |
} |