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.gerryai.planning.model.domain.Precondition.java

/**
 * Private constructor to create an empty precondition.
 */
private Precondition() {
    precondition = Optional.absent();
}

From source file:com.facebook.buck.android.ProguardTranslatorFactory.java

private static Optional<Map<String, String>> loadOptionalRawMap(ExecutionContext context,
        Optional<Path> proguardFullConfigFile, Optional<Path> proguardMappingFile) throws IOException {
    if (!proguardFullConfigFile.isPresent()) {
        return Optional.absent();
    }/*from  w ww. j  ava2s  .  c  om*/

    ProjectFilesystem projectFilesystem = context.getProjectFilesystem();
    Path pathToProguardConfig = proguardFullConfigFile.get();

    // Proguard doesn't print a mapping when obfuscation is disabled.
    boolean obfuscationSkipped = Iterables.any(projectFilesystem.readLines(pathToProguardConfig),
            Predicates.equalTo("-dontobfuscate"));
    if (obfuscationSkipped) {
        return Optional.absent();
    }

    List<String> lines = projectFilesystem.readLines(proguardMappingFile.get());
    return Optional.of(ProguardMapping.readClassMapping(lines));
}

From source file:org.anhonesteffort.flock.crypto.KeyHelper.java

public static Optional<MasterCipher> getMasterCipher(Context context) throws IOException {
    Optional<byte[]> cipherKeyBytes = KeyStore.getCipherKey(context);
    Optional<byte[]> macKeyBytes = KeyStore.getMacKey(context);

    if (!cipherKeyBytes.isPresent() || !macKeyBytes.isPresent())
        return Optional.absent();

    SecretKey cipherKey = new SecretKeySpec(cipherKeyBytes.get(), "AES");
    SecretKey macKey = new SecretKeySpec(cipherKeyBytes.get(), "SHA256");

    return Optional.of(new MasterCipher(cipherKey, macKey));
}

From source file:org.anhonesteffort.flock.sync.key.KeySyncUtil.java

private static Optional<HidingCalDavCollection> getKeyCollection(Context context, DavAccount account)
        throws PropertyParseException, DavException, IOException {
    HidingCalDavStore store = DavAccountHelper.getHidingCalDavStore(context, account, null);
    Optional<String> calendarHomeSet = store.getCalendarHomeSet();
    if (calendarHomeSet.isPresent())
        return store.getCollection(calendarHomeSet.get().concat(PATH_KEY_COLLECTION));

    return Optional.absent();
}

From source file:google.registry.util.UrlFetchUtils.java

private static Optional<String> getHeaderFirstInternal(Iterable<HTTPHeader> hdrs, String name) {
    name = Ascii.toLowerCase(name);/*from  w w  w  .j  a v  a2s  . com*/
    for (HTTPHeader header : hdrs) {
        if (Ascii.toLowerCase(header.getName()).equals(name)) {
            return Optional.of(header.getValue());
        }
    }
    return Optional.absent();
}

From source file:se.sics.dozy.DozyResult.java

public DozyResult(Status status, Optional<String> details) {
    this.status = status;
    this.details = details;
    this.value = Optional.absent();
}

From source file:org.pau.assetmanager.business.HistoricalStockValuesBusiness.java

public static Optional<HistoricalStockValue> getHistoricalLastValueForSymbol(String symbol) {
    String query = "select historicalStockValue from HistoricalStockValue historicalStockValue where symbol = :symbol order by year desc, month desc";
    List<HistoricalStockValue> optionalHistoricalStockValue = DaoFunction
            .<HistoricalStockValue>querySimpleListFunction("symbol", symbol).apply(query);
    if (optionalHistoricalStockValue.size() > 0) {
        return Optional.of(optionalHistoricalStockValue.iterator().next());
    } else {/*from   w ww.  j av  a2 s  .  c  om*/
        return Optional.absent();
    }
}

From source file:com.dowdandassociates.gentoo.bootstrap.BootstrapInstanceInformation.java

public BootstrapInstanceInformation() {
    instance = Optional.absent();
    volume = Optional.absent();
}

From source file:org.opendaylight.unimgr.mef.nrp.common.MountPointHelper.java

/**
 * Find a node's NETCONF mount point and then retrieve its DataBroker.
 * e.g./*w  ww .  j  a  va2  s.c  om*/
 * http://localhost:8080/restconf/config/network-topology:network-topology/
 *        topology/topology-netconf/node/{nodeName}/yang-ext:mount/
 */
public static Optional<DataBroker> getDataBroker(MountPointService mountService, String nodeName) {
    NodeId nodeId = new NodeId(nodeName);

    InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
            .child(Node.class, new NodeKey(nodeId)).build();

    final Optional<MountPoint> nodeOptional = mountService.getMountPoint(nodeInstanceId);

    if (!nodeOptional.isPresent()) {
        return Optional.absent();
    }

    MountPoint nodeMountPoint = nodeOptional.get();
    return Optional.of(nodeMountPoint.getService(DataBroker.class).get());
}

From source file:org.jclouds.aws.filters.FormSignerUtils.java

private static Optional<String> getAnnotatedApiVersion(Invocation invocation) {
    final Invokable<?, ?> invokable = invocation.getInvokable();
    if (invokable.isAnnotationPresent(ApiVersionOverride.class)) {
        return Optional.fromNullable(invokable.getAnnotation(ApiVersionOverride.class).value());
    } else {// w  ww.j a v a  2  s . c o  m
        final Class<?> owner = invokable.getOwnerType().getRawType();
        if (owner.isAnnotationPresent(ApiVersionOverride.class)) {
            return Optional.fromNullable(owner.getAnnotation(ApiVersionOverride.class).value());
        }
    }
    return Optional.absent();
}