当前位置: 首页>>代码示例>>Java>>正文


Java Option.of方法代码示例

本文整理汇总了Java中io.vavr.control.Option.of方法的典型用法代码示例。如果您正苦于以下问题:Java Option.of方法的具体用法?Java Option.of怎么用?Java Option.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vavr.control.Option的用法示例。


在下文中一共展示了Option.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: failsWhenFailingConstraint

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void failsWhenFailingConstraint() {
    Example example = new Example();
    example.three = Option.of(2);
    Set<ConstraintViolation<Example>> violations = validator.validate(example);
    assertThat(violations).hasSize(1);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:8,代码来源:ValueValidatedValueUnwrapperTest.java

示例2: succeedsWhenConstraintsMet

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void succeedsWhenConstraintsMet() {
    Example example = new Example();
    example.three = Option.of(10);
    Set<ConstraintViolation<Example>> violations = validator.validate(example);
    assertThat(violations).isEmpty();
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:8,代码来源:ValueValidatedValueUnwrapperTest.java

示例3: notBlankFailsWhenPresentButBlank

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void notBlankFailsWhenPresentButBlank() {
    Example example = new Example();
    example.notBlank = Option.of("\t");
    Set<ConstraintViolation<Example>> violations = validator.validate(example);
    assertThat(violations).hasSize(1);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:8,代码来源:ValueValidatedValueUnwrapperTest.java

示例4: should_fail_if_option_does_not_contain_the_expected_object_reference

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_the_expected_object_reference() {
  Option<String> actual = Option.of("not-expected");
  String expectedValue = "something";

  thrown.expectAssertionError(shouldContainSame(actual, expectedValue).create());

  assertThat(actual).containsSame(expectedValue);
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:10,代码来源:OptionAssert_containsSame_Test.java

示例5: should_fail_if_option_contains_equal_but_not_same_value

import io.vavr.control.Option; //导入方法依赖的package包/类
@SuppressWarnings("RedundantStringConstructorCall")
@Test
public void should_fail_if_option_contains_equal_but_not_same_value() {
  Option<String> actual = Option.of(new String("something"));
  String expectedValue = new String("something");

  thrown.expectAssertionError(shouldContainSame(actual, expectedValue).create());

  assertThat(actual).containsSame(expectedValue);
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:11,代码来源:OptionAssert_containsSame_Test.java

示例6: should_fail_if_option_does_not_contain_expected_value

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() throws Exception {
  Option<String> actual = Option.of("not-expected");
  String expectedValue = "something";

  thrown.expectAssertionError(shouldContain(actual, expectedValue).create());

  assertThat(actual).contains(expectedValue);
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:10,代码来源:OptionAssert_contains_Test.java

示例7: should_fail_if_option_does_not_contain_expected_value

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() throws Exception {
  Option<Foo> actual = Option.of(new Foo("something"));
  Foo expectedValue = new Foo("something else");

  thrown.expectAssertionError(shouldContain(actual, expectedValue).create());

  assertThat(actual).usingValueComparator(FOO_COMPARATOR).contains(expectedValue);
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:10,代码来源:OptionAssert_contains_usingValueComparator_Test.java

示例8: should_fail_if_option_does_not_contain_expected_value

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() {
  Option<Foo> actual = Option.of(new Foo("something"));
  Foo expectedValue = new Foo("something else");

  thrown.expectAssertionError(shouldContain(actual, expectedValue).create());

  assertThat(actual).usingFieldByFieldValueComparator().contains(expectedValue);
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:10,代码来源:OptionAssert_contains_usingFieldByFieldValueComparator_Test.java

示例9: should_fail_if_option_contains_other_type_than_required

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_contains_other_type_than_required() {
  Option<ParentClass> actual = Option.of(new ParentClass());

  Throwable thrown = catchThrowable(
      () -> assertThat(actual).containsInstanceOf(OtherClass.class));

  assertThat(thrown).isInstanceOf(AssertionError.class)
                    .hasMessage(shouldContainInstanceOf(actual, OtherClass.class).create());
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:11,代码来源:OptionAssert_containsInstanceOf_Test.java

示例10: should_fail_if_Option_is_present

import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_Option_is_present() throws Exception {
  Option<String> actual = Option.of("not-empty");

  thrown.expectAssertionError(shouldBeEmpty(actual).create());

  assertThat(actual).isEmpty();
}
 
开发者ID:assertj,项目名称:assertj-vavr,代码行数:9,代码来源:OptionAssert_isEmpty_Test.java

示例11: add

import io.vavr.control.Option; //导入方法依赖的package包/类
@Override
public ContainerBuilder<Option<?>> add(Object it) {
    optional = Option.of(it);
    return this;
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:6,代码来源:OptionContainerFactory.java

示例12: optionFilledResult

import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("/option-filled")
public Option<String> optionFilledResult() {
    return Option.of("option");
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:6,代码来源:VavrApplication.java

示例13: some

import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("option-some")
public Option<String> some() {
    return Option.of("Foobar");
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:6,代码来源:ValueMessageBodyWriterTest.java

示例14: setPublicFacingIP

import io.vavr.control.Option; //导入方法依赖的package包/类
public void setPublicFacingIP(final String ip) {
    publicFacingIP = Option.of(ip);
}
 
开发者ID:fabzo,项目名称:kraken,代码行数:4,代码来源:EnvironmentContext.java

示例15: DatabaseWait

import io.vavr.control.Option; //导入方法依赖的package包/类
public DatabaseWait(final String connectionUrl, final Duration atMost) {
    this.connectionUrl = Option.of(connectionUrl);
    this.atMost = atMost;
}
 
开发者ID:fabzo,项目名称:kraken,代码行数:5,代码来源:DatabaseWait.java


注:本文中的io.vavr.control.Option.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。