當前位置: 首頁>>代碼示例>>Java>>正文


Java Optional.absent方法代碼示例

本文整理匯總了Java中com.google.common.base.Optional.absent方法的典型用法代碼示例。如果您正苦於以下問題:Java Optional.absent方法的具體用法?Java Optional.absent怎麽用?Java Optional.absent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Optional的用法示例。


在下文中一共展示了Optional.absent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseAttribute

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Override
public Optional<ObjectName> parseAttribute(final String attrName, final Object value) {
    if (value == null) {
        return Optional.absent();
    }

    Util.checkType(value, ObjectNameAttributeMappingStrategy.MappedDependency.class);

    ObjectNameAttributeMappingStrategy.MappedDependency mappedDep =
            (ObjectNameAttributeMappingStrategy.MappedDependency) value;
    String serviceName = mappedDep.getServiceName();
    String refName = mappedDep.getRefName();
    String namespace = mappedDep.getNamespace();
    LOG.trace("Getting service instance by service name {} : {} and ref name {}", namespace, serviceName, refName);

    ObjectName on = serviceTracker.getByServiceAndRefName(namespace, serviceName, refName);

    LOG.debug("Attribute {} : {} parsed to type {}", attrName, value, getOpenType());
    return Optional.of(on);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:21,代碼來源:ObjectNameAttributeResolvingStrategy.java

示例2: prepareRootRB

import com.google.common.base.Optional; //導入方法依賴的package包/類
protected RuntimeBeanEntry prepareRootRB(final List<RuntimeBeanEntry> children) {

        final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
        doReturn("DataSchemaNode").when(nodeContainer).toString();
        return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
                "module-name", "ModuleName", true, Optional.<String> absent(),
                Collections.<AttributeIfc> emptyList(), children,
                Collections.<Rpc> emptySet());
    }
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:10,代碼來源:RuntimeRegistratorTest.java

示例3: RestoreSnapshot

import com.google.common.base.Optional; //導入方法依賴的package包/類
public RestoreSnapshot(QualifiedName name,
                      @Nullable GenericProperties genericProperties) {
    this.name = name;
    this.properties = Optional.fromNullable(genericProperties);
    this.tableList = Optional.absent();

}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:8,代碼來源:RestoreSnapshot.java

示例4: getSqlTypeFamily

import com.google.common.base.Optional; //導入方法依賴的package包/類
public static Optional<SqlTypeFamily> getSqlTypeFamily(final LayoutField field) {
  try {
    return Optional.of(SqlTypeFamily.valueOf(field.getTypeFamily()));
  } catch (final IllegalArgumentException ex) {
    return Optional.absent();
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:8,代碼來源:TypeUtils.java

示例5: FeedbackBlend

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Inject
public FeedbackBlend(FeedbackBlendView view, FeedbackStyleNameConstants styleNameConstants, RootPanelDelegate rootPanelDelegate,
                     UserInteractionHandlerFactory userInteractionHandlerFactory, TouchReservationCommand touchReservationCommand) {
    this.view = view;
    this.styleNameConstants = styleNameConstants;
    textFeedback = Optional.absent();

    rootPanelDelegate.getRootPanel().add(view.asWidget());
    userInteractionHandlerFactory.applyUserClickHandler(createClickCommand(), view.asWidget());

    EventHandlerProxy userTouchStartHandler = userInteractionHandlerFactory.createUserTouchStartHandler(touchReservationCommand);
    userTouchStartHandler.apply(view.asWidget());
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:14,代碼來源:FeedbackBlend.java

示例6: getCurrentValue

import com.google.common.base.Optional; //導入方法依賴的package包/類
private <T> Optional<SimpleMdsValue<T>> getCurrentValue(final List<SimpleMdsValue<T>> simpleMdsValues, UserAccountCreationAttribute userAccountCreationAttribute) {
    List<SimpleMdsValue<T>> currentValues = ImmutableList.copyOf(simpleMdsValues.stream()
            .filter(simpleMdsValue -> simpleMdsValue.getTo() == null)
            .collect(toList()));
    if (currentValues.size() > 1) {
        String message = MessageFormat.format("There cannot be multiple current values for {0} attribute.", userAccountCreationAttribute.getAttributeName());
        throw new WebApplicationException(new IllegalStateException(message), Response.Status.INTERNAL_SERVER_ERROR);
    }
    if (currentValues.isEmpty()) {
        return Optional.absent();
    }
    return Optional.of(currentValues.get(0));
}
 
開發者ID:alphagov,項目名稱:verify-matching-service-adapter,代碼行數:14,代碼來源:UserAccountCreationAttributeExtractor.java

示例7: getLayout

import com.google.common.base.Optional; //導入方法依賴的package包/類
private Optional<Layout> getLayout(final Acceleration acceleration, LayoutId layoutId) {
  for (Layout layout : AccelerationUtils.getAllLayouts(acceleration)) {
    if (layout.getId().equals(layoutId)) {
      return Optional.fromNullable(layout);
    }
  }
  return Optional.absent();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:9,代碼來源:BaseAccelerationResource.java

示例8: aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled

import com.google.common.base.Optional; //導入方法依賴的package包/類
private void aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(SessionId sessionId) throws JsonProcessingException {
    SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
    InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto =
            new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService,
                    translatedAuthnRequest.getId(),
                    msaEntityId,
                    Optional.<String>absent(),
                    Optional.<LevelOfAssurance>absent());
    samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
    List<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
    configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);

    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
    postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:16,代碼來源:MatchingServiceResourcesIntegrationTest.java

示例9: getOnlyChildElementWithSameNamespaceOptionally

import com.google.common.base.Optional; //導入方法依賴的package包/類
public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally() {
    Optional<XmlElement> child = getOnlyChildElementOptionally();
    if (child.isPresent()
            && child.get().getNamespaceOptionally().isPresent()
            && getNamespaceOptionally().isPresent()
            && getNamespaceOptionally().get().equals(child.get().getNamespaceOptionally().get())) {
        return child;
    }
    return Optional.absent();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:11,代碼來源:XmlElement.java

示例10: createTree

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Override
Optional<BinaryNode> createTree(int size, Random rng) {
  Optional<BinaryNode> root = Optional.absent();
  for (int i = 0; i < size; i++) {
    root = Optional.of(new BinaryNode(rng.nextInt(), root, Optional.<BinaryNode>absent()));
  }
  return root;
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:9,代碼來源:BinaryTreeTraverserBenchmark.java

示例11: getErrorMessage

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Override
public Optional<String> getErrorMessage(Object objectValue, Annotation annotation) {
    if (isCorrect(objectValue, annotation))
        return Optional.absent();

    return Optional.of(TranslationConfig.getTranslation(Message.NOT_NULL_ERROR_MESSAGE));
}
 
開發者ID:pablo127,項目名稱:GPigValidator,代碼行數:8,代碼來源:NotNullValidator.java

示例12: shouldNotSetState_whenIsEmpty

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Test
public void shouldNotSetState_whenIsEmpty() {
    // given
    Optional<JavaScriptObject> jsoOptional = Optional.absent();
    when(stateSaver.getExternalState()).thenReturn(jsoOptional);

    // when
    testObj.setSavedStateInExternal(externalApi);

    // then
    verify(externalApi, never()).setStateOnExternal(any(JavaScriptObject.class));
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:13,代碼來源:ExternalStateSetterTest.java

示例13: typeAdaptersProvider

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Value.Lazy
public Optional<AbstractDeclaring> typeAdaptersProvider() {
  Optional<DeclaringType> typeDefining =
      declaringType().isPresent()
          ? Optional.of(declaringType().get().associatedTopLevel())
          : Optional.<DeclaringType>absent();

  Optional<TypeAdaptersMirror> typeDefined =
      typeDefining.isPresent()
          ? typeDefining.get().typeAdapters()
          : Optional.<TypeAdaptersMirror>absent();

  Optional<TypeAdaptersMirror> packageDefined = packageOf().typeAdapters();

  if (packageDefined.isPresent()) {
    if (typeDefined.isPresent()) {
      report()
          .withElement(typeDefining.get().element())
          .annotationNamed(TypeAdaptersMirror.simpleName())
          .warning("@%s is also used on the package, this type level annotation is ignored",
              TypeAdaptersMirror.simpleName());
    }
    return Optional.<AbstractDeclaring>of(packageOf());
  }

  return typeDefined.isPresent()
      ? Optional.<AbstractDeclaring>of(typeDefining.get())
      : Optional.<AbstractDeclaring>absent();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:Proto.java

示例14: load

import com.google.common.base.Optional; //導入方法依賴的package包/類
@Override
public Optional<T> load(final Class<? extends T> key) {

    final AdapterBuilder<? extends T, D> builder = createBuilder(key);
    for(final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
        final D deleg = getDelegate(reqDeleg);
        if(deleg != null) {
            builder.addDelegate(reqDeleg,deleg);
        } else {
            return Optional.absent();
        }
    }
    return  Optional.<T>of(builder.build());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:15,代碼來源:AdapterLoader.java

示例15: getParent

import com.google.common.base.Optional; //導入方法依賴的package包/類
public Optional<? extends IJoint> getParent()
{
    return Optional.absent();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:5,代碼來源:ModelBlockAnimation.java


注:本文中的com.google.common.base.Optional.absent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。