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.opendaylight.yangtools.yang.data.api.schema.tree.spi.LazyMutableContainerNode.java

@Override
public Optional<TreeNode> getChild(final PathArgument childId) {
    final TreeNode modified = getModifiedChild(childId);
    if (modified != null) {
        return Optional.of(modified);
    }//ww w.j  av  a2  s  .c o m

    return Optional.fromNullable(AbstractContainerNode.getChildFromData(getData(), childId, getVersion()));
}

From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.aiml.types.AttributeImplementation.java

/**
 * Vytvo atribut./*from   www .  j a  v a2 s.c  o m*/
 * 
 * @param name
 *            nzev
 * @param value
 *            hodnota
 * @param namespace
 *            prostor jmen
 * @return atribut
 */
public static AttributeImplementation create(final String name, final String value, final URI namespace) {
    Preconditions.checkNotNull(name);
    Preconditions.checkNotNull(value);
    Preconditions.checkNotNull(namespace);
    Preconditions.checkArgument(!name.isEmpty());

    return new AttributeImplementation(name, value, Optional.of(namespace));
}

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

@Override
public Optional<ImmutableSortedSet<T>> getOptionalValue() {
    return Optional.of(ImmutableSortedSet.<T>of());
}

From source file:com.streamsets.pipeline.hbase.api.common.producer.HBaseColumn.java

public void setQualifier(byte[] qualifier) {
    this.qualifier = Optional.of(qualifier);
}

From source file:org.jclouds.openstack.keystone.v2_0.functions.PresentWhenAdminURLExistsForIdentityService.java

@Override
public Optional<Object> apply(ClassMethodArgsAndReturnVal input) {
    //TODO: log and return absent when the admin url for identity service isn't available
    return Optional.of(input.getReturnVal());
}

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

public Optional<Long> create(final Entry newEntry, final long userId) {
    final long newEntryId = entryDao.create(newEntry.getTitle(), newEntry.getMessage(), newEntry.isDraft(),
            userId);//from www  . ja  va  2s . c  om
    return Optional.of(newEntryId);
}

From source file:gobblin.hive.HivePartitionComparator.java

@SuppressWarnings("unchecked")
public T compareValues() {
    if (!this.result) {
        compare(Optional.of(((HivePartition) this.existingUnit).getValues()),
                Optional.of(((HivePartition) this.newUnit).getValues()));
    }//from   w  w w .j a v  a 2s. co m
    return (T) this;
}

From source file:org.pau.assetmanager.business.HistoricalStockValuesBusiness.java

public static Optional<HistoricalStockValue> getHistoricalLastValueForSymbol(String symbol) {
    String query = "select historicalStockValue from HistoricalStockValue historicalStockValue where symbol = :symbol order by year desc, month desc";
    List<HistoricalStockValue> optionalHistoricalStockValue = DaoFunction
            .<HistoricalStockValue>querySimpleListFunction("symbol", symbol).apply(query);
    if (optionalHistoricalStockValue.size() > 0) {
        return Optional.of(optionalHistoricalStockValue.iterator().next());
    } else {/*from   w ww.  j  av  a 2s. co m*/
        return Optional.absent();
    }
}

From source file:com.facebook.buck.shell.ExportFileBuilder.java

public ExportFileBuilder setOut(String out) {
    arg.out = Optional.of(out);
    return this;
}

From source file:org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml.CompositeAttributeWritingStrategy.java

@Override
public void writeElement(Element parentElement, String namespace, Object value) {
    Util.checkType(value, Map.class);

    Element innerNode = XmlUtil.createElement(document, key, Optional.of(namespace));

    Map<?, ?> map = (Map<?, ?>) value;

    for (Entry<?, ?> innerObjectEntry : map.entrySet()) {
        Util.checkType(innerObjectEntry.getKey(), String.class);

        String innerKey = (String) innerObjectEntry.getKey();
        Object innerValue = innerObjectEntry.getValue();

        innerStrats.get(innerKey).writeElement(innerNode, namespace, innerValue);
    }// w w  w .j a v a 2 s.  c  om
    parentElement.appendChild(innerNode);
}