Java Code Examples for com.google.common.base.Optional.absent()

The following are Jave code examples for showing how to use absent() of the com.google.common.base.Optional class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: hashsdn-controller   File: ObjectNameAttributeResolvingStrategy.java   View Source Code Vote up 6 votes
@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);
}
 
Example 2
Project: hashsdn-controller   File: RuntimeRegistratorTest.java   View Source Code Vote up 5 votes
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());
    }
 
Example 3
Project: Elasticsearch   File: RestoreSnapshot.java   View Source Code Vote up 5 votes
public RestoreSnapshot(QualifiedName name,
                      @Nullable GenericProperties genericProperties) {
    this.name = name;
    this.properties = Optional.fromNullable(genericProperties);
    this.tableList = Optional.absent();

}
 
Example 4
Project: dremio-oss   File: TypeUtils.java   View Source Code Vote up 5 votes
public static Optional<SqlTypeFamily> getSqlTypeFamily(final LayoutField field) {
  try {
    return Optional.of(SqlTypeFamily.valueOf(field.getTypeFamily()));
  } catch (final IllegalArgumentException ex) {
    return Optional.absent();
  }
}
 
Example 5
Project: empiria.player   File: FeedbackBlend.java   View Source Code Vote up 5 votes
@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());
}
 
Example 6
Project: verify-matching-service-adapter   File: UserAccountCreationAttributeExtractor.java   View Source Code Vote up 5 votes
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));
}
 
Example 7
Project: dremio-oss   File: BaseAccelerationResource.java   View Source Code Vote up 5 votes
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();
}
 
Example 8
Project: verify-hub   File: MatchingServiceResourcesIntegrationTest.java   View Source Code Vote up 5 votes
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);
}
 
Example 9
Project: hashsdn-controller   File: XmlElement.java   View Source Code Vote up 5 votes
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();
}
 
Example 10
Project: guava-mock   File: BinaryTreeTraverserBenchmark.java   View Source Code Vote up 5 votes
@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;
}
 
Example 11
Project: GPigValidator   File: NotNullValidator.java   View Source Code Vote up 5 votes
@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));
}
 
Example 12
Project: empiria.player   File: ExternalStateSetterTest.java   View Source Code Vote up 5 votes
@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));
}
 
Example 13
Project: GitHub   File: Proto.java   View Source Code Vote up 5 votes
@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();
}
 
Example 14
Project: hashsdn-controller   File: AdapterLoader.java   View Source Code Vote up 5 votes
@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());
}
 
Example 15
Project: CustomWorldGen   File: ModelBlockAnimation.java   View Source Code Vote up 4 votes
public Optional<? extends IJoint> getParent()
{
    return Optional.absent();
}
 
Example 16
Project: CustomWorldGen   File: DataSerializers.java   View Source Code Vote up 4 votes
public Optional<UUID> read(PacketBuffer buf)
{
    return !buf.readBoolean() ? Optional.<UUID>absent() : Optional.of(buf.readUuid());
}
 
Example 17
Project: dremio-oss   File: MaterializationExpander.java   View Source Code Vote up 4 votes
public Optional<DremioRelOptMaterialization> expand(MaterializationDescriptor descriptor) {

    final RelNode deserializedPlan = deserializePlan(descriptor.getPlan());

    RelNode queryRel = deserializedPlan.accept(ScanConverter.INSTANCE);

    // for incremental update, we need to rewrite the queryRel so that it propogates the UPDATE_COLUMN and
    // adds it as a grouping key in aggregates
    if (descriptor.getIncrementalUpdateSettings().isIncremental()) {
      RelShuttle shuttle;
      if (descriptor.getIncrementalUpdateSettings().getUpdateField() == null) {
        shuttle = IncrementalUpdateUtils.FILE_BASED_SUBSTITUTION_SHUTTLE;
      } else {
        shuttle = new SubstitutionShuttle(descriptor.getIncrementalUpdateSettings().getUpdateField());
      }
      queryRel = queryRel.accept(shuttle);
    }


    RelNode tableRel = expandSchemaPath(descriptor.getPath());

    if (tableRel == null) {
      return Optional.absent();
    }

    BatchSchema schema = ((ScanCrel) tableRel).getBatchSchema();

    tableRel = tableRel.accept(ScanConverter.INSTANCE);
    tableRel = tableRel.accept(new IncrementalUpdateUtils.RemoveDirColumn(queryRel.getRowType()));

    // Namespace table removes UPDATE_COLUMN from scans, but for incremental materializations, we need to add it back
    // to the table scan
    if (descriptor.getIncrementalUpdateSettings().isIncremental()) {
      tableRel = tableRel.accept(IncrementalUpdateUtils.ADD_MOD_TIME_SHUTTLE);
    }

    // Check that the table rel row type matches that of the query rel,
    // if so, cast the table rel row types to the query rel row types.
    tableRel = MoreRelOptUtil.createCastRel(tableRel, queryRel.getRowType());

    return Optional.of(new DremioRelOptMaterialization(
      tableRel,
      queryRel,
      descriptor.getIncrementalUpdateSettings(),
      descriptor.getLayoutInfo(),
      descriptor.getMaterializationId(),
      schema,
      descriptor.getExpirationTimestamp()
    ));
  }
 
Example 18
Project: Elasticsearch   File: KillStatement.java   View Source Code Vote up 4 votes
public KillStatement() {
    this.jobId = Optional.absent();
}
 
Example 19
Project: empiria.player   File: DragGapViewImpl.java   View Source Code Vote up 4 votes
@Override
public void removeContent() {
    container.clear();
    optionalDraggable = Optional.absent();
}
 
Example 20
Project: guava-mock   File: MediaType.java   View Source Code Vote up 4 votes
private static MediaType createConstant(String type, String subtype) {
  MediaType mediaType =
      addKnownType(new MediaType(type, subtype, ImmutableListMultimap.<String, String>of()));
  mediaType.parsedCharset = Optional.absent();
  return mediaType;
}