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


Java Optional.isPresent方法代码示例

本文整理汇总了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);
}
 
开发者ID:TriangleLeft,项目名称:Flashcards,代码行数:27,代码来源:PhoneDelegate.java

示例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();
    }
}
 
开发者ID:TriangleLeft,项目名称:Flashcards,代码行数:16,代码来源:BaseActivity.java

示例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();
    }
}
 
开发者ID:TriangleLeft,项目名称:Flashcards,代码行数:15,代码来源:BaseFragment.java

示例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);
    }
}
 
开发者ID:TriangleLeft,项目名称:Flashcards,代码行数:8,代码来源:VocabularyWordPresenter.java

示例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);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:12,代码来源:OptionalMatcher.java

示例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;
}
 
开发者ID:danrien,项目名称:projectBlue,代码行数:30,代码来源:FakeConnectionProvider.java

示例7: matches

import com.annimon.stream.Optional; //导入方法依赖的package包/类
@Override
public boolean matches(Optional<T> argument) {
    return argument != null && argument.isPresent();
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:5,代码来源:OptionalMatcher.java


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