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

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

Introduction

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

Prototype

public static <T> Optional<T> absent() 

Source Link

Document

Returns an Optional instance with no contained reference.

Usage

From source file:org.sonar.server.permission.ws.ProjectWsRef.java

public static Optional<ProjectWsRef> newOptionalWsProjectRef(@Nullable String uuid, @Nullable String key) {
    if (uuid == null && key == null) {
        return Optional.absent();
    }/*www  .  ja v  a2s .c  o m*/

    return Optional.of(new ProjectWsRef(uuid, key));
}

From source file:io.urmia.md.model.storage.ObjectName.java

public static Optional<ObjectName> of(String path) {
    if (path == null)
        return Optional.absent();
    try {/*  w w  w .j  a v  a 2s  . c  om*/
        return of(new URI(path));
    } catch (URISyntaxException e) {
        return Optional.absent();
    }
}

From source file:org.opendaylight.protocol.bgp.testtool.BGPPeerBuilder.java

static void createPeer(final BGPDispatcher dispatcher, final Arguments arguments,
        final InetSocketAddress localAddress, final BGPSessionListener sessionListener,
        final BgpParameters bgpParameters) {
    final AsNumber as = arguments.getAs();
    final BGPSessionPreferences proposal = new BGPSessionPreferences(as, arguments.getHoldTimer(),
            new BgpId(localAddress.getAddress().getHostAddress()), as, Collections.singletonList(bgpParameters),
            Optional.absent());
    final StrictBGPPeerRegistry strictBGPPeerRegistry = new StrictBGPPeerRegistry();
    if (arguments.getInitiateConnection()) {
        for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
            strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener,
                    proposal);//from  w w  w . jav a  2 s . c  o m
            addFutureListener(localAddress, ((BGPDispatcherImpl) dispatcher).createClient(localAddress,
                    remoteAddress, strictBGPPeerRegistry, RETRY_TIMER));
        }
    } else {
        for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
            strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener,
                    proposal);
        }
        addFutureListener(localAddress, dispatcher.createServer(strictBGPPeerRegistry, localAddress));
    }
    LOG.debug("{} {}", sessionListener, proposal);
}

From source file:im.dadoo.teak.web.ao.FileAO.java

public Optional<String> save(MultipartFile file) throws IllegalStateException, IOException {
    if (file != null && !file.isEmpty()) {
        String srcName = Util.createFileName();
        File src = new File(srcName);
        file.transferTo(src);/*  w  ww . jav a 2s. c o  m*/
        Optional<String> dst = this.qiniuFileBO.save(src);
        src.delete();
        return dst;
    } else {
        return Optional.absent();
    }
}

From source file:org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.SimpleAttributeMappingStrategy.java

@Override
public Optional<String> mapAttribute(Object value) {
    if (value == null) {
        return Optional.absent();
    }//from   w w  w .j  av a  2 s.c o  m

    String expectedClass = getOpenType().getClassName();
    String realClass = value.getClass().getName();
    Preconditions.checkArgument(realClass.equals(expectedClass),
            "Type mismatch, expected " + expectedClass + " but was " + realClass);

    WriterPlugin prefferedPlugin = writerPlugins.get(value.getClass().getCanonicalName());
    prefferedPlugin = prefferedPlugin == null ? writerPlugins.get(DEFAULT_WRITER_PLUGIN) : prefferedPlugin;
    return Optional.of(prefferedPlugin.writeObject(value));
}

From source file:com.streamsets.pipeline.hbase.api.common.producer.HBaseColumn.java

public HBaseColumn() {
    cf = Optional.absent();
    qualifier = Optional.absent();
    timestamp = OptionalLong.empty();
}

From source file:cf.janga.hook.core.DefaultPluginRegistration.java

public DefaultPluginRegistration(String name, String description, String version, String pluginClass,
        String pluginFileName) {/*from   w w w  . j  a  v a2 s .  co  m*/
    super(name, description, version);
    this.loadingError = Optional.absent();
    this.pluginClass = pluginClass;
    this.pluginFileName = pluginFileName;
}

From source file:at.ac.univie.isc.asio.tool.JdbcTools.java

/**
 * Attempt to find the classname of a {@code Driver}, which supports the given jdbc url.
 *
 * @param url the jdbc url/*  w w  w  .  jav a2  s.  co m*/
 * @return the driver class supporting the given jdbc url or nothing if unknown
 */
public static Optional<String> inferDriverClass(final String url) {
    Optional<String> result = Optional.absent();
    if (url != null) {
        if (url.startsWith("jdbc:mysql:")) {
            result = MYSQL_DRIVER;
        } else if (url.startsWith("jdbc:h2:")) {
            result = H2_DRIVER;
        }
    }
    return result;
}

From source file:org.dswarm.graph.gdm.utils.NodeTypeUtils.java

public static Optional<NodeType> getNodeTypeByGDMNodeType(
        final Optional<org.dswarm.graph.json.NodeType> optionalNodeType,
        final Optional<Boolean> optionalIsType) {

    if (!optionalNodeType.isPresent()) {

        return Optional.absent();
    }/* w w  w . j  a va2  s  .  com*/

    final NodeType nodeType;

    switch (optionalNodeType.get()) {

    case Literal:

        nodeType = NodeType.Literal;

        break;
    case Resource:

        if (optionalIsType.isPresent()) {

            if (Boolean.FALSE.equals(optionalIsType.get())) {

                nodeType = NodeType.Resource;
            } else {

                nodeType = NodeType.TypeResource;
            }
        } else {

            nodeType = NodeType.Resource;
        }

        break;
    case BNode:

        if (optionalIsType.isPresent()) {

            if (Boolean.FALSE.equals(optionalIsType.get())) {

                nodeType = NodeType.BNode;
            } else {

                nodeType = NodeType.TypeBNode;
            }
        } else {

            nodeType = NodeType.BNode;
        }

        break;
    default:

        nodeType = null;
    }

    return Optional.fromNullable(nodeType);
}

From source file:com.github.rinde.rinsim.ui.renderers.RenderHelper.java

RenderHelper() {
    gc = Optional.absent();
    vp = Optional.absent();
}