本文整理汇总了Java中com.annimon.stream.Optional.of方法的典型用法代码示例。如果您正苦于以下问题:Java Optional.of方法的具体用法?Java Optional.of怎么用?Java Optional.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.annimon.stream.Optional
的用法示例。
在下文中一共展示了Optional.of方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentUserData
import com.annimon.stream.Optional; //导入方法依赖的package包/类
private Optional<UserData> getCurrentUserData() {
return Optional.of(UserData.create(
Collections.unmodifiableList(languages),
avatarUrl,
userName,
uiLanguage,
learningLanguage));
}
示例2: onWordSelectedShouldShowWord
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Test
public void onWordSelectedShouldShowWord() throws Exception {
Optional<VocabularyWord> word = Optional.of(mock(VocabularyWord.class));
presenter.onCreate();
presenter.onBind(view);
presenter.showWord(word);
verify(view).showWord(word);
}
示例3: onBackPressedFromWordShouldReturnToList
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Test
public void onBackPressedFromWordShouldReturnToList() {
Optional<VocabularyWord> word = Optional.of(mock(VocabularyWord.class));
presenter.onCreate();
presenter.onBind(view);
presenter.showWord(word);
reset(view);
presenter.onBackPressed();
verify(view).showList();
}
示例4: testIsPresent
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Test
public void testIsPresent() {
Optional<Integer> optional = Optional.of(5);
assertThat(optional, isPresent());
assertThat(optional, not(isEmpty()));
assertThat(isPresent(), description(is("Optional value should be present")));
}
示例5: testHasValue
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Test
public void testHasValue() {
Optional<String> optional = Optional.of("text");
assertThat(optional, hasValue("text"));
assertThat(optional, not(hasValue("test")));
assertThat(hasValue(42), description(is("Optional value is <42>")));
}
示例6: testHasValueThat
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Test
public void testHasValueThat() {
Optional<String> optional = Optional.of("text");
assertThat(optional, hasValueThat(startsWith("te")));
assertThat(hasValueThat(is(42)), description(is("Optional value is <42>")));
}
示例7: getCurrentLearningLanguage
import com.annimon.stream.Optional; //导入方法依赖的package包/类
public Optional<Language> getCurrentLearningLanguage() {
List<Language> languages = getSortedLanguages();
return languages.size() > 0 ? Optional.of(languages.get(0)) : Optional.empty();
}