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.DefaultJobCatalogListenerImpl.java

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

From source file:info.rynkowski.hamsterclient.data.repository.datasources.db.entities.mapper.DbFactMapper.java

public @Nonnull Fact transform(@Nonnull DbFact dbFact) {
    Calendar startTime = dbFact.getStartTime().getCalendar();

    Optional<Calendar> endTime = Optional.absent();
    if (dbFact.getEndTime().isPresent()) {
        endTime = Optional.of(dbFact.getEndTime().get().getCalendar());
    }/*w  w w.  ja v  a  2s .c o  m*/

    return new Fact.Builder() //
            .id(dbFact.getId()).activity(dbFact.getActivity()).category(dbFact.getCategory())
            .startTime(startTime).endTime(endTime).description(dbFact.getDescription()).tags(dbFact.getTags())
            .build();
}

From source file:org.opennms.newts.stress.Query.java

Optional<Duration> getResolution() {
    return Optional.of(m_resolution);
}

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:com.atlassian.jira.rest.client.api.domain.Operations.java

public Operation getOperationById(final String operationId) {
    return accept(new OperationVisitor<Operation>() {
        @Override//from ww  w . ja v  a  2  s . co m
        public Optional<Operation> visit(Operation operation) {
            return operationId.equals(operation.getId()) ? Optional.of(operation)
                    : Optional.<Operation>absent();
        }
    }).orNull();
}

From source file:com.redhat.hss.bugzilla.model.Bug.java

public Bug(int id) {
    this.id = Optional.of(id);
}

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

@Override
protected Optional<MatchState> matchResult(ExpressionTree tree, VisitorState state) {
    MethodSymbol sym = getConstructor(tree);
    if (sym == null) {
        return Optional.absent();
    }/*from ww  w . jav a 2 s  .  c o  m*/
    return Optional.of(MatchState.create(sym.owner.type, sym));
}

From source file:ch.css.workingdiary.service.EntryService.java

public Optional<List<Entry>> getEntriesByUserId(final long userId) {
    final List<Entry> entries = entryDao.getEntriesByUserId(userId);
    return Optional.of(entries);
}

From source file:com.treasuredata.client.model.TDSavedQueryBuilder.java

public TDSavedQueryBuilder setName(String name) {
    this.name = Optional.of(name);
    return this;
}

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

@Override
protected Optional<MatchState> matchResult(ExpressionTree item, MatchState baseResult, VisitorState state) {
    if (predicate.apply(baseResult.ownerType(), state)) {
        return Optional.of(baseResult);
    }//from   w  ww.java 2s .c om
    return Optional.absent();
}