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

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

Introduction

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

Prototype

public static <T> Optional<T> of(T reference) 

Source Link

Document

Returns an Optional instance containing the given non-null reference.

Usage

From source file:org.apache.gobblin.runtime.std.DefaultJobExecutionStateListenerImpl.java

public DefaultJobExecutionStateListenerImpl(Logger log) {
    this(Optional.of(log));
}

From source file:bear.task.TaskResult.java

public TaskResult(Throwable e) {
    this.result = Result.ERROR;
    exception = Optional.of(e);
}

From source file:com.facebook.buck.util.cache.MultiProjectFileHashCache.java

private Optional<Pair<FileHashCache, Path>> lookup(Path path) {
    for (ProjectFileHashCache cache : projectCaches) {
        ProjectFilesystem filesystem = cache.getFilesystem();
        Optional<Path> relativePath = filesystem.getPathRelativeToProjectRoot(path);
        if (relativePath.isPresent() && !filesystem.isIgnored(relativePath.get())) {
            return Optional.of(new Pair<FileHashCache, Path>(cache, relativePath.get()));
        }/*w w w  .  j a v  a 2s.com*/
    }
    return Optional.absent();
}

From source file:com.qcadoo.mes.costCalculation.hooks.OrderDetailsHooksCC.java

public void onBeforeRender(final ViewDefinitionState view) {
    orderDetailsRibbonHelper.setButtonEnabled(view, "costCalculate", "costCalculate",
            OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY,
            Optional.of("orders.ribbon.message.mustChangeTechnologyState"));
}

From source file:org.opennms.newts.cassandra.search.ResourceMetadata.java

public ResourceMetadata(Meter metricReqs, Meter attributeReqs, Meter metricMisses, Meter attributeMisses) {
    m_metricReqs = Optional.of(checkNotNull(metricReqs, "metricsReqs argument"));
    m_attributeReqs = Optional.of(checkNotNull(attributeReqs, "attributesReqs argument"));
    m_metricMisses = Optional.of(checkNotNull(metricMisses, "metricsMisses argument"));
    m_attributeMisses = Optional.of(checkNotNull(attributeMisses, "attributesMisses argument"));
}

From source file:com.axemblr.provisionr.cloudstack.commands.CommandTestSupport.java

@Before
public void setUp() throws Exception {
    defaultProviderConfig = mock(DefaultProviderConfig.class);
    byteArrayOutputStream = new ByteArrayOutputStream();
    out = new PrintStream(byteArrayOutputStream);
    client = mock(CloudStackClient.class);
    when(defaultProviderConfig.createProvider()).thenReturn(Optional.of(mock(Provider.class)));
}

From source file:com.google.errorprone.matchers.method.MethodSignatureMatcherImpl.java

@Override
protected Optional<MatchState> matchResult(ExpressionTree item, MatchState method, VisitorState state) {
    // TODO(cushon): build a way to match signatures (including varargs ones!) that doesn't
    // rely on MethodSymbol#toString().
    boolean matches = method.sym().getSimpleName().contentEquals(methodName)
            || method.sym().toString().equals(methodName);
    return matches ? Optional.of(method) : Optional.<MatchState>absent();
}

From source file:org.locationtech.geogig.osm.internal.log.ReadOSMFilterFile.java

@Override
protected Optional<String> _call() {
    Preconditions.checkNotNull(entry);//from   www.  java 2 s .c o m
    URL url = command(ResolveOSMLogfile.class).call();
    File logfile = new File(url.getFile());
    File file = new File(logfile.getParentFile(), "filter" + entry.getId().toString());
    if (!file.exists()) {
        return Optional.absent();
    }
    try {
        List<String> lines = Files.readLines(file, Charsets.UTF_8);
        String line = Joiner.on("\n").join(lines);
        return Optional.of(line);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.mayocat.entity.EntityData.java

public <O> Optional<O> getData(Class<O> clazz) {
    if (data.containsKey(clazz)) {
        return Optional.of((O) data.get(clazz));
    }/*from w  w w  . j  a va2 s  .  com*/
    return Optional.absent();
}