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.sweep.webservice.toolbox.Result.java

public static Result badRequest(String reason) {
    return new Result(Status.BAD_REQUEST, Optional.of(reason), Optional.absent());
}

From source file:io.crate.planner.node.management.KillPlan.java

public KillPlan(UUID id) {
    this.id = id;
    this.jobToKill = Optional.absent();
}

From source file:de.flapdoodle.logparser.StreamMatcher.java

@Override
public Optional<IMatch<StreamEntry>> match(IReader reader, IBackBuffer backBuffer) throws IOException {
    Optional<String> optionalFirstLine = reader.nextLine();
    if (optionalFirstLine.isPresent()) {
        if (!optionalFirstLine.get().startsWith(">")) {
            return Optional.<IMatch<StreamEntry>>of(new StreamMatch(optionalFirstLine.get()));
        }//from w w  w .  j  a v  a 2  s .  c  o m
    }
    return Optional.absent();
}

From source file:io.github.cdelmas.spike.dropwizard.infrastructure.auth.FacebookTokenAuthenticator.java

@Override
public Optional<User> authenticate(String token) throws AuthenticationException {
    Try<User> user = accessTokenVerificationCommandFactory.createVerificationCommand(token).executeCommand();
    return user.toJavaOptional().map(Optional::of).orElse(Optional.absent());
}

From source file:se.sics.kompics.network.netty.MessageWrapper.java

MessageWrapper(Msg msg) {
    this.msg = msg;
    this.notify = Optional.absent();
}

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

public static Optional<RegistryExtraFlowLogic> newInstanceForTld(String tld) throws EppException {
    if (extraLogicOverrideMap.containsKey(tld)) {
        try {//www .j a  va 2  s .c  o m
            return Optional
                    .<RegistryExtraFlowLogic>of(extraLogicOverrideMap.get(tld).getConstructor().newInstance());
        } catch (ReflectiveOperationException ex) {
            throw new CommandFailedException();
        }
    }
    return Optional.absent();
}

From source file:org.gradle.model.internal.core.EmptyReferenceProjection.java

@Override
public Optional<String> getValueDescription(MutableModelNode mutableModelNode) {
    return Optional.absent();
}

From source file:org.opendaylight.netvirt.qosservice.UuidUtil.java

Optional<Uuid> newUuidIfValidPattern(String possibleUuid) {
    Preconditions.checkNotNull(possibleUuid, "possibleUuid == null");

    if (uuidPattern == null) {
        // Thread safe because it really doesn't matter even if we were to do this initialization more than once
        if (Uuid.PATTERN_CONSTANTS.size() != 1) {
            throw new IllegalStateException("Uuid.PATTERN_CONSTANTS.size() != 1");
        }/*  w w w  .j  av  a2  s .co  m*/
        uuidPattern = Pattern.compile(Uuid.PATTERN_CONSTANTS.get(0));
    }

    if (uuidPattern.matcher(possibleUuid).matches()) {
        return Optional.of(new Uuid(possibleUuid));
    } else {
        return Optional.absent();
    }
}

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

public HiveProcessingEntity(HiveDataset hiveDataset, Table table) {
    this(hiveDataset, table, Optional.absent());
}

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

/**
 * root:        /owner//* w  ww . jav a2  s. co  m*/
 * namespace:   /owner/ns/path
 */
public static Optional<ObjectName> of(URI uri) {

    if (uri == null)
        return Optional.absent();

    final String uriPath = appendTrailingSlash(uri.getPath());

    if (!startsWith('/', uriPath))
        return Optional.absent();

    int secondSlashPos = uriPath.indexOf('/', 1);

    if (secondSlashPos == -1)
        return Optional.absent();

    final String owner = uriPath.substring(1, secondSlashPos);

    if (isEmpty(owner)) // no owner
        return Optional.absent();

    // todo: only if mds.userExists(owner)
    if (secondSlashPos == uriPath.length() - 1) // special case of /user/ only. for listing root namespaces
        return Optional.of(new ObjectName(owner, Namespace.ROOT, "/", ""));

    String nsPath = uriPath.substring(secondSlashPos + 1);

    int thirdSlashPos = nsPath.indexOf('/');

    if (thirdSlashPos <= 0) // no namespace
        return Optional.absent();

    final String nsName = nsPath.substring(0, thirdSlashPos);

    final ObjectName.Namespace ns = ObjectName.Namespace.of(nsName);
    if (ns.unknown())
        return Optional.absent(); // unknown ns

    final String normalPath = normalize(nsPath.substring(thirdSlashPos));
    final String parent = UnixPathUtils.parent(normalPath);
    final String name = UnixPathUtils.name(normalPath);

    final ObjectName on = new ObjectName(owner, ns, parent, name);

    return Optional.of(on);
}