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:se.sics.ktoolbox.cc.heartbeat.util.CCValueFactory.java

public static List<KAddress> extractHeartbeatSrc(Collection<byte[]> values) {
    List<KAddress> result = new ArrayList<>();
    for (byte[] value : values) {
        ByteBuf buf = Unpooled.wrappedBuffer(value);
        result.add((KAddress) Serializers.fromBinary(buf, Optional.absent()));
    }//from  w ww  .  j a va 2  s  .co  m
    return result;
}

From source file:org.opendaylight.controller.netconf.persist.impl.PersisterImpl.java

public static Optional<PersisterImpl> createFromProperties(BundleContext bundleContext) {
    String storageAdapterClass = bundleContext.getProperty(STORAGE_ADAPTER_CLASS_PROP);
    StorageAdapter storage;// w w w .j  ava2 s.  c o m
    if (storageAdapterClass == null || storageAdapterClass.equals("")) {
        return Optional.absent();
    }

    try {
        storage = StorageAdapter.class
                .cast(resolveClass(storageAdapterClass, StorageAdapter.class).newInstance());
        storage.setProperties(bundleContext);

    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new IllegalArgumentException("Unable to instantiate storage adapter from " + storageAdapterClass,
                e);
    }
    return Optional.of(new PersisterImpl(storage));
}

From source file:google.registry.flows.domain.RegistryExtraFlowLogicProxy.java

public static <D extends DomainBase> Optional<RegistryExtraFlowLogic> newInstanceForDomain(@Nullable D domain)
        throws EppException {
    if (domain == null) {
        return Optional.absent();
    } else {/*www  .  j a v a 2 s.  c  o m*/
        return newInstanceForTld(domain.getTld());
    }
}

From source file:org.opendaylight.yangtools.yang.data.impl.codec.EmptyStringCodec.java

private EmptyStringCodec() {
    super(Optional.absent(), Void.class);
}

From source file:org.mayocat.addons.util.AddonUtils.java

/**
 * Finds a addon group definition in a list of group definitions. The priority of the group definitions is order in
 * which they are passed : first passed has the highest priority, last passed the lowest.
 *
 * @param name the name of the addon group definition to find
 * @param groupDefinitions the list of group definitions
 * @return the first definition found, or absent if none is found
 *///from   w  ww  .  j a va  2s.co m
public static Optional<AddonGroupDefinition> findAddonGroupDefinition(String name,
        Map<String, AddonGroupDefinition>... groupDefinitions) {
    for (Map<String, AddonGroupDefinition> groupDefinition : groupDefinitions) {
        if (groupDefinition.containsKey(name)) {
            return Optional.of(groupDefinition.get(name));
        }
    }
    return Optional.absent();
}

From source file:com.github.kevints.mesos.scheduler.server.LibprocessServletUtils.java

static Optional<String> parseMessageType(HttpServletRequest req) {
    String pathInfo = req.getPathInfo();
    if (pathInfo == null) {
        return Optional.absent();
    }/* w ww.  j a v  a  2  s. c  o m*/

    return Optional.of(Paths.get(pathInfo).getFileName().toString());
}

From source file:org.immutables.fixture.couse.AbstractB.java

default void use() {
    B b = B.builder().a(A.builder().build()).aO(Optional.absent()).build();

    b.toString();
}

From source file:de.Keyle.MyPet.util.UpdateCheck.java

public static Optional<String> checkForUpdate(String plugin) {
    try {// w  w w  .  j av  a 2 s .c om
        String parameter = "";
        parameter += "&package=" + MyPetApi.getCompatUtil().getInternalVersion();
        parameter += "&build=" + MyPetVersion.getBuild();

        // no data will be saved on the server
        String content = Util.readUrlContent("http://update.mypet-plugin.de/" + plugin + "?" + parameter);
        JSONParser parser = new JSONParser();
        JSONObject result = (JSONObject) parser.parse(content);

        if (result.containsKey("latest")) {
            latest = result.get("latest").toString();
            return Optional.of(latest);
        }
    } catch (Exception ignored) {
    }
    return Optional.absent();
}

From source file:harp.util.FileUtil.java

/**
 * Find a file with the given base name, searching upward from the given starting directory.
 *
 * @param filename the base filename to look for
 * @param startingPath the starting directory to search upward from
 *
 * @return an {@code Optional} containing the Path of the file if found, or an empty Optional
 *     otherwise/*from   w ww.  j a  va 2 s  . c o  m*/
 */
public static Optional<Path> findUpward(String filename, Path startingPath) {
    Preconditions.checkNotNull(filename);
    Preconditions.checkArgument(!filename.contains(File.separator));
    Preconditions.checkArgument(Files.isDirectory(startingPath));
    Path possibleRootDir = startingPath;
    while (possibleRootDir != null) {
        Path possiblePath = possibleRootDir.resolve(filename);
        if (Files.isRegularFile(possiblePath)) {
            return Optional.of(possiblePath);
        } else {
            possibleRootDir = possibleRootDir.getParent();
        }
    }
    return Optional.absent();
}

From source file:de.azapps.tools.Log.java

public static void disableLoggingToFile() {
    writeToFile = false;
    fileWriter = Optional.absent();
}