Example usage for com.google.common.base Optional orNull

List of usage examples for com.google.common.base Optional orNull

Introduction

In this page you can find the example usage for com.google.common.base Optional orNull.

Prototype

@Nullable
public abstract T orNull();

Source Link

Document

Returns the contained instance if it is present; null otherwise.

Usage

From source file:org.jclouds.rackspace.cloudidentity.v2_0.functions.AuthenticateApiKeyCredentials.java

@Override
protected Access authenticateWithTenantName(Optional<String> tenantId, ApiKeyCredentials apiKeyCredentials) {
    return api.authenticateWithTenantNameAndCredentials(tenantId.orNull(), apiKeyCredentials);
}

From source file:net.pterodactylus.sone.web.ViewPostPage.java

/**
 * {@inheritDoc}/*from w w w.ja va2s .  c o  m*/
 */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext)
        throws RedirectException {
    super.processTemplate(request, templateContext);
    String postId = request.getHttpRequest().getParam("post");
    boolean raw = request.getHttpRequest().getParam("raw").equals("true");
    Optional<Post> post = webInterface.getCore().getPost(postId);
    templateContext.set("post", post.orNull());
    templateContext.set("raw", raw);
}

From source file:com.eucalyptus.context.ContextPropagationChannelInterceptor.java

@Override
protected void populatePropagatedContext(final Optional<Context> contextOptional, final Message<?> message,
        final MessageChannel messageChannel) {
    Contexts.threadLocal(contextOptional.orNull());
}

From source file:org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials.java

@Override
protected Access authenticateWithTenantId(Optional<String> tenantId,
        PasswordCredentials apiAccessKeyCredentials) {
    return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
}

From source file:net.wouterdanes.docker.remoteapi.MiscService.java

/**
 * Builds an image based on the passed tar archive. Optionally names &amp; tags the image
 * @param tarArchive the tar archive to use as a source for the image
 * @param name the name and optional tag of the image.
 * @return the ID of the created image/*from  w ww  . jav  a 2 s .co m*/
 */
public String buildImage(byte[] tarArchive, Optional<String> name) {
    String jsonStream = getServiceEndPoint().path("/build").queryParam("q", true).queryParam("t", name.orNull())
            .queryParam("forcerm").request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.entity(tarArchive, "application/tar"), String.class);

    Matcher matcher = BUILD_IMAGE_ID_EXTRACTION_PATTERN.matcher(jsonStream);
    if (!matcher.matches()) {
        throw new DockerException("Can't obtain ID from build output stream.", jsonStream);
    }
    return matcher.group(1);
}

From source file:org.semanticweb.owlapi.sparql.ui.SPARQLQueryResultsTableModel.java

public Object getValueAt(int rowIndex, int columnIndex) {
    SolutionMapping binding = result.getBindingAt(rowIndex);
    Variable variable = indexVariableMap.get(columnIndex);
    if (variable != null) {
        Optional<RDFTerm> termForVariable = binding.getTermForVariable(variable);
        return termForVariable.orNull();
    } else {/*from   ww  w .j  av  a  2 s.  co  m*/
        return null;
    }
}

From source file:io.crate.executor.transport.task.elasticsearch.facet.UpdateFacetExecutor.java

public UpdateFacetExecutor(Map<String, Object> doc, Optional<Long> version, SearchContext searchContext,
        TransportUpdateAction updateAction) {
    this.collector = new UpdateCollector(doc, version.orNull(), updateAction, searchContext);
}

From source file:org.apache.gobblin.data.management.conversion.hive.entities.QueryBasedHiveConversionEntity.java

public QueryBasedHiveConversionEntity(ConvertibleHiveDataset convertibleHiveDataset,
        SchemaAwareHiveTable hiveTable, Optional<SchemaAwareHivePartition> hivePartition) {
    super(convertibleHiveDataset, hiveTable, Optional.fromNullable(hivePartition.orNull()));
    this.convertibleHiveDataset = convertibleHiveDataset;
    this.hiveTable = hiveTable;
    this.hivePartition = hivePartition;
    this.queries = Lists.newArrayList();
}

From source file:org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials.java

@Override
protected Access authenticateWithTenantId(Optional<String> tenantId,
        ApiAccessKeyCredentials apiAccessKeyCredentials) {
    return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
}

From source file:org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials.java

@Override
protected Access authenticateWithTenantName(Optional<String> tenantName,
        PasswordCredentials apiAccessKeyCredentials) {
    return api.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials);
}