本文整理汇总了Java中com.annimon.stream.Optional.isPresent方法的典型用法代码示例。如果您正苦于以下问题:Java Optional.isPresent方法的具体用法?Java Optional.isPresent怎么用?Java Optional.isPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.annimon.stream.Optional
的用法示例。
在下文中一共展示了Optional.isPresent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showWord
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
public void showWord(Optional<VocabularyWord> word) {
if (!word.isPresent()) {
// In phone view, just don't open this screen
// FIXME: when we turn screen from tablet to phone, current state is word
// But when we have no words, we don't show anything
// Either also show "no data" here and remove return
// Or make sure that if we are moving from tablet to phone and and there are no words, show list
// Ugh...
return;
}
hideFragment(vocabularListFragment);
fab.hide();
if (vocabularyWordFragment == null) {
vocabularyWordFragment = new VocabularyWordFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.main_container, vocabularyWordFragment, VocabularyWordFragment.TAG)
.commitNow();
} else {
showFragment(vocabularyWordFragment);
}
vocabularyWordFragment.getPresenter().showWord(word);
setArrowIndicator(false);
}
示例2: onCreate
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
logger.debug("onCreate() called with: savedInstanceState = [{}]", savedInstanceState);
super.onCreate(savedInstanceState);
Optional<Component> restoredComponent =
getApplicationComponent().componentManager().restoreComponent(getClass());
this.component = restoredComponent.orElse(buildComponent());
inject();
// If we didn't had restored component, it's a new one, run presenter's onCreate
if (!restoredComponent.isPresent()) {
getPresenter().onCreate();
}
}
示例3: onCreate
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@CallSuper
@Override
public void onCreate(Bundle savedInstanceState) {
logger.debug("onCreate() called with: savedInstanceState = [{}]", savedInstanceState);
super.onCreate(savedInstanceState);
Optional<Component> optional = getApplicationComponent().componentManager().restoreComponent(getClass());
this.component = optional.orElse(buildComponent());
inject();
if (!optional.isPresent()) {
getPresenter().onCreate();
}
}
示例4: showWord
import com.annimon.stream.Optional; //导入方法依赖的package包/类
public void showWord(Optional<VocabularyWord> word) {
if (word.isPresent()) {
applyState(view -> view.showWord(word.get()));
} else {
applyState(IVocabularyWordView::showEmpty);
}
}
示例5: matchesSafely
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(Optional<T> optional, Description mismatchDescription) {
if (!optional.isPresent()) {
mismatchDescription.appendText("Optional was empty");
return false;
}
final T value = optional.get();
mismatchDescription.appendText("Optional value ");
matcher.describeMismatch(value, mismatchDescription);
return matcher.matches(value);
}
示例6: getConnection
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
public HttpURLConnection getConnection(String... params) throws IOException {
final HttpURLConnection mockConnection = mock(HttpURLConnection.class);
when(mockConnection.getResponseCode()).thenReturn(404);
CarelessOneParameterFunction<String[], byte[]> mappedResponse = mappedResponses.get(new HashSet<>(Arrays.asList(params)));
if (mappedResponse == null) {
final Optional<Set<String>> optionalResponse = Stream.of(mappedResponses.keySet())
.filter(set -> Stream.of(set).allMatch(sp -> Stream.of(params).anyMatch(p -> p.matches(sp))))
.findFirst();
if (optionalResponse.isPresent())
mappedResponse = mappedResponses.get(optionalResponse.get());
}
if (mappedResponse == null) return mockConnection;
try {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(mappedResponse.resultFrom(params));
when(mockConnection.getInputStream()).thenReturn(inputStream);
} catch (Throwable throwable) {
when(mockConnection.getInputStream()).thenThrow(throwable);
}
when(mockConnection.getResponseCode()).thenReturn(200);
return mockConnection;
}
示例7: matches
import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
public boolean matches(Optional<T> argument) {
return argument != null && argument.isPresent();
}