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:springfox.bean.validators.plugins.BeanValidators.java

@VisibleForTesting
static <T extends Annotation> Optional<T> annotationFrom(AnnotatedMember nullableMember,
        Class<T> annotationType) {

    Optional<AnnotatedMember> member = Optional.fromNullable(nullableMember);
    Optional<T> notNull = Optional.absent();
    if (member.isPresent()) {
        notNull = FluentIterable.from(member.get().annotations()).filter(annotationType).first();
    }/*from   w ww .  j  a v  a 2  s . c om*/
    return notNull;
}

From source file:com.gradleware.tooling.toolingmodel.repository.internal.AbstractOmniClasspathEntry.java

protected static Optional<List<OmniClasspathAttribute>> getClasspathAttributes(EclipseClasspathEntry entry) {
    DomainObjectSet<? extends ClasspathAttribute> attributes;
    try {/*  w  ww . ja  v a 2s. c o  m*/
        attributes = entry.getClasspathAttributes();
    } catch (UnsupportedMethodException e) {
        return Optional.absent();
    }
    Builder<OmniClasspathAttribute> builder = ImmutableList.builder();
    for (ClasspathAttribute attribute : attributes) {
        builder.add(DefaultOmniClasspathAttribute.from(attribute));
    }
    return Optional.<List<OmniClasspathAttribute>>of(builder.build());
}

From source file:net.openaudiomc.groups.GroupManager.java

public Optional<PlayerGroup> getGroup(String group) {
    if (groups.get(group) == null) {
        return Optional.absent();
    } else {/*from   w  w  w  .java 2  s. c  o  m*/
        return Optional.of(groups.get(group));
    }
}

From source file:com.forerunnergames.tools.common.Result.java

public static <V, R extends Result<V>> Optional<R> firstFailedFrom(final Iterable<R> results) {
    Arguments.checkIsNotNull(results, "results");
    Arguments.checkHasNoNullElements(results, "results");

    for (final R result : results) {
        if (result.failed())
            return Optional.of(result);
    }//from w  w w  . j a  va2s  . co  m

    return Optional.absent();
}

From source file:edmtools.Metric.java

public Metric(int versionMask, int lowByteBit, String protoPath) {
    this.versionMask = versionMask;
    this.lowByteBit = lowByteBit;
    this.highByteBit = Optional.absent();
    this.protoPath = protoPath;
    this.scaleFactor = Optional.absent();
}

From source file:io.urmia.job.pub.ZkJobStatusMonitor.java

@Override
public Optional<JobStatus> getStatus(String jobId, JobStatusUpdateHandler handler) throws Exception {
    String path = getGlobalZkPath(jobId);

    if (client.checkExists().forPath(path) == null)
        return Optional.absent();

    byte[] statusBytes = client.getData().forPath(path);
    String statusJobString = new String(statusBytes).trim();

    log.info("statusJobString: {}", statusJobString);

    JobStatus.Stats counters = handler.getStats();

    JobStatus jobStatus = new JobStatus(statusJobString, counters);

    return Optional.of(jobStatus);
}

From source file:com.facebook.buck.rules.coercer.OCamlSourceTypeCoercer.java

@Override
public Optional<OCamlSource> getOptionalValue() {
    return Optional.absent();
}

From source file:se.sics.ktoolbox.cc.heartbeat.util.CCKeyFactory.java

public static Identifier extractOverlay(byte[] schemaPrefix, Key key) {
    ByteBuffer bbKey = key.getWrapper();
    bbKey.position(schemaPrefix.length);
    int overlaySize = bbKey.get();
    byte[] overlayId = new byte[overlaySize];
    bbKey.get(overlayId);//from w  w  w .j  a  va2  s .  c  o m
    ByteBuf buf = Unpooled.wrappedBuffer(overlayId);
    return (Identifier) Serializers.fromBinary(buf, Optional.absent());
}

From source file:io.macgyver.core.resource.ResourceProvider.java

public Optional<Resource> findResourceByPath(String path) throws IOException {
    try {//w  ww .j  a v  a 2  s .  co  m
        return Optional.fromNullable(getResourceByPath(path));
    } catch (IOException e) {

    }
    return Optional.absent();
}