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:cz.cuni.mff.ms.brodecva.botnicek.ide.aiml.elements.template.implementations.MultiPredicateCondition.java

/**
 * Vytvo prvek./*  w  w w. j a  v a 2 s. c  o  m*/
 * 
 * @param defaultItem
 *            vchoz poloka, jej obsah bude zpracovn v ppad, e
 *            neuspje dn s prediktem a hodnotou
 * @param items
 *            poloky s nzvy testovanch predikt vzory pro hodnotu
 *            prediktu
 * @return prvek
 */
public static MultiPredicateCondition create(final DefaultListItem defaultItem,
        final List<? extends NameAndValueListItem> items) {
    Preconditions.checkNotNull(defaultItem);

    return new MultiPredicateCondition(Optional.of(defaultItem), items);
}

From source file:org.mayocat.shop.payment.store.jdbi.DBIGatewayDataStore.java

@Override
public Optional<GatewayCustomerData> getCustomerData(Customer customer, String gatewayId) {
    GatewayCustomerData result = dao.getCustomerData(customer.getId(), gatewayId);
    if (result == null) {
        return Optional.absent();
    }/*from  w  ww  .j a v  a 2s  . com*/
    return Optional.of(result);
}

From source file:gobblin.data.management.policy.SelectBeforeTimeBasedPolicy.java

public SelectBeforeTimeBasedPolicy(Config conf) {
    super(Optional.of(getMinLookbackTime(conf)), Optional.<Period>absent());
}

From source file:org.sosy_lab.cpachecker.cfa.model.java.JStatementEdge.java

@Override
public Optional<JStatement> getRawAST() {
    return Optional.of((JStatement) statement);
}

From source file:appeng.items.tools.quartz.ToolQuartzHoe.java

public ToolQuartzHoe(final AEFeature feature) {
    super(ToolMaterial.IRON);

    this.feature = feature;
    this.handler = new ItemFeatureHandler(EnumSet.of(feature, AEFeature.QuartzHoe), this, this,
            Optional.of(feature.name()));
}

From source file:org.opendaylight.controller.netconf.test.tool.ModuleBuilderCapability.java

@Override
public Optional<String> getModuleNamespace() {
    return Optional.of(input.getNamespace().toString());
}

From source file:appeng.core.features.DamagedItemDefinition.java

public DamagedItemDefinition(@Nonnull final IStackSrc source) {
    Preconditions.checkNotNull(source);//  w  ww  . j a v a2 s  .c  o m

    if (source.isEnabled()) {
        this.source = Optional.of(source);
    } else {
        this.source = Optional.absent();
    }
}

From source file:li.klass.fhem.behavior.dim.DiscreteDimmableBehavior.java

static Optional<DiscreteDimmableBehavior> behaviorFor(SetList setList) {

    List<String> keys = setList.getSortedKeys();
    ImmutableList<String> foundDimStates = from(keys).filter(DIMMABLE_STATE).toList();

    return foundDimStates.isEmpty() ? Optional.<DiscreteDimmableBehavior>absent()
            : Optional.of(new DiscreteDimmableBehavior(foundDimStates));
}

From source file:org.arbeitspferde.groningen.utility.PinnedClock.java

/**
 * @param time The initial time at which this clock shall report.
 * @param incrementQueryBy The amount by which the clock will be mutated on each query for time.
 *///from  w w  w.  j a  va  2  s.  co  m
public PinnedClock(final long time, final long incrementQueryBy) {
    this.time = new AtomicLong(time);
    this.incrementQueryBy = Optional.of(incrementQueryBy);
}

From source file:org.geogit.geotools.plumbing.ListOp.java

/**
 * Executes the list operation on the provided data store.
 * /*from  w w  w. java2  s. c om*/
 * @return a list of all tables, or Optional.absent() if none were found
 */
@Override
public Optional<List<String>> call() {
    if (dataStore == null) {
        throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED);
    }

    List<String> features = new ArrayList<String>();

    boolean foundTable = false;

    List<Name> typeNames;
    try {
        typeNames = dataStore.getNames();
    } catch (Exception e) {
        throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES);
    }

    for (Name typeName : typeNames) {
        foundTable = true;

        features.add(typeName.toString());
    }

    if (!foundTable) {
        return Optional.absent();
    }
    return Optional.of(features);
}