io.reactivex.Single.contains()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中io.reactivex.Single.contains()方法的一些代码示例,展示了Single.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.contains()方法的具体详情如下:
包路径:io.reactivex.Single
类名称:Single
方法名:contains

Single.contains介绍

[英]Signals true if the current Single signals a success value that is Object-equals with the value provided. Scheduler: contains does not operate by default on a particular Scheduler.
[中]如果当前单个对象发出成功值的信号,且该值与提供的值相等,则表示为真。调度程序:默认情况下,contains不会在特定调度程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void containsNull() {
  just1.contains(null);
}

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void containsComparerNull() {
  just1.contains(1, null);
}

代码示例来源:origin: ReactiveX/RxJava

/**
 * Signals true if the current Single signals a success value that is Object-equals with the value
 * provided.
 * <dl>
 * <dt><b>Scheduler:</b></dt>
 * <dd>{@code contains} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param value the value to compare against the success value of this Single
 * @return the new Single instance
 * @since 2.0
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Single<Boolean> contains(Object value) {
  return contains(value, ObjectHelper.equalsPredicate());
}

代码示例来源:origin: redisson/redisson

/**
 * Signals true if the current Single signals a success value that is Object-equals with the value
 * provided.
 * <dl>
 * <dt><b>Scheduler:</b></dt>
 * <dd>{@code contains} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param value the value to compare against the success value of this Single
 * @return the new Single instance
 * @since 2.0
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Single<Boolean> contains(Object value) {
  return contains(value, ObjectHelper.equalsPredicate());
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void contains() {
  Single.just(1).contains(1).test().assertResult(true);
  Single.just(2).contains(1).test().assertResult(false);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void comparerThrows() {
  Single.just(1)
  .contains(2, new BiPredicate<Object, Object>() {
    @Override
    public boolean test(Object a, Object b) throws Exception {
      throw new TestException();
    }
  })
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
  public void error() {
    Single.error(new TestException())
    .contains(2)
    .test()
    .assertFailure(TestException.class);
  }
}

相关文章

微信公众号

最新文章

更多