当前位置: 首页>>代码示例>>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;未经允许,请勿转载。