本文整理汇总了Java中io.vavr.control.Option.none方法的典型用法代码示例。如果您正苦于以下问题:Java Option.none方法的具体用法?Java Option.none怎么用?Java Option.none使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.control.Option
的用法示例。
在下文中一共展示了Option.none方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConcatOptions
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void testConcatOptions() {
assertThat(
concatOptions(List.of(Option.some("he"), Option.none(), Option.some("hm"))),
is(List.of("he", "hm"))
);
Function1<String, Option<String>> removeFoo = s ->
s.equals("foo") ? Option.none() : Option.some(s);
assertThat(
pipe(
(List<String> x) -> map(removeFoo, x),
concatOptions()
).apply(List.of("Hey", "foo", "keep")),
is(List.of("Hey", "keep"))
);
}
示例2: fromJsonArray
import io.vavr.control.Option; //导入方法依赖的package包/类
@Override
Option<?> fromJsonArray(JsonArray arr, Type type, Type[] subTypes, JsonDeserializationContext ctx) throws JsonParseException {
if (arr.size() < 1 || arr.size() > 2) {
throw new JsonParseException("bad json format");
}
String status = arr.get(0).getAsString();
if ("defined".equals(status)) {
if (arr.size() == 2) {
Object el = subTypes.length > 0 ? ctx.deserialize(arr.get(1), subTypes[0]) : arr.get(1);
return Option.some(el);
} else {
throw new JsonParseException("expected array size: 2");
}
} else {
return Option.none();
}
}
示例3: notNullFailsWhenAbsent
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void notNullFailsWhenAbsent() {
Example example = new Example();
example.notNull = Option.none();
Set<ConstraintViolation<Example>> violations = validator.validate(example);
assertThat(violations).hasSize(1);
}
示例4: should_fail_if_option_is_empty
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_is_empty() {
Option<Object> actual = Option.none();
Throwable thrown = catchThrowable(() -> assertThat(actual).containsInstanceOf(Object.class));
assertThat(thrown).isInstanceOf(AssertionError.class)
.hasMessage(OptionShouldBePresent.shouldBePresent().create());
}
示例5: head
import io.vavr.control.Option; //导入方法依赖的package包/类
public static Option<Character> head(String string) {
return string.isEmpty() ? Option.none() : Option.some(string.charAt(0));
}
示例6: head_String
import io.vavr.control.Option; //导入方法依赖的package包/类
public static Option<Character> head_String(String string) {
return string.isEmpty() ? Option.none() : Option.some(string.charAt(0));
}
示例7:
import io.vavr.control.Option; //导入方法依赖的package包/类
public static Option<Character> headᐸStringᐳ(String string) {
return string.isEmpty() ? Option.none() : Option.some(string.charAt(0));
}
示例8: optionNoneResult
import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("/option-none")
public Option<String> optionNoneResult() {
return Option.none();
}
示例9: none
import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("option-none")
public Option<String> none() {
return Option.none();
}