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:google.registry.rde.PendingDeposit.java

static PendingDeposit create(String tld, DateTime watermark, RdeMode mode, CursorType cursor,
        Duration interval) {/* ww  w .ja v  a  2s.co  m*/
    return new AutoValue_PendingDeposit(false, tld, watermark, mode, Optional.of(cursor), Optional.of(interval),
            Optional.<String>absent(), Optional.<Integer>absent());
}

From source file:paperparcel.PaperParcelGenerator.java

@Override
Optional<? extends Element> getElementForErrorReporting(PaperParcelDescriptor input) {
    return Optional.of(input.element());
}

From source file:net.revelc.code.blazon.types.numeric.LongRangeType.java

@Override
protected Optional<Long> checkPostconditions(final Long value) {
    if (!range.contains(value)) {
        throw new IllegalArgumentException(value + " is not in the range " + range.toString());
    }//from  w  ww .  j  a va 2 s .  co  m
    return Optional.of(value);
}

From source file:com.facebook.presto.block.BlockUtils.java

public static BlockIterable toBlocks(DataSize dataSize, int positionCount, Iterable<Block> blocks) {
    return new BlocksIterableAdapter(Iterables.get(blocks, 0).getTupleInfo(), Optional.of(dataSize),
            Optional.of(positionCount), blocks);
}

From source file:retrofit.processor.GwtCompatibility.java

GwtCompatibility(TypeElement type) {
    Optional<AnnotationMirror> gwtCompatibleAnnotation = Optional.absent();
    List<? extends AnnotationMirror> annotations = type.getAnnotationMirrors();
    for (AnnotationMirror annotation : annotations) {
        Name name = annotation.getAnnotationType().asElement().getSimpleName();
        if (name.contentEquals("GwtCompatible")) {
            gwtCompatibleAnnotation = Optional.of(annotation);
        }//from   ww  w. j  a va 2 s.c  o m
    }
    this.gwtCompatibleAnnotation = gwtCompatibleAnnotation;
}

From source file:com.dangdang.ddframe.rdb.sharding.parsing.parser.context.OrderItem.java

public OrderItem(final String owner, final String name, final OrderType type, final Optional<String> alias) {
    this.owner = Optional.of(owner);
    this.name = Optional.of(name);
    this.type = type;
    this.alias = alias;
}

From source file:org.opendaylight.controller.netconf.util.capability.YangModuleCapability.java

@Override
public Optional<String> getModuleName() {
    return Optional.of(moduleName);
}

From source file:br.com.objectos.way.core.code.jdt.TypeWrapperSimple.java

@Override
Optional<PackageInfo> getPackageInfo() {
    Optional<PackageInfo> res = super.getPackageInfo();

    ITypeBinding binding = type.resolveBinding();
    if (binding != null) {
        IPackageBinding pkg = binding.getPackage();
        PackageInfo packageInfo = IPackageBindingWrapper.wrapperOf(pkg).toPackageInfo();
        res = Optional.of(packageInfo);
    }//from   w  ww  .j a va  2s . c  o  m

    return res;
}

From source file:eu.numberfour.n4js.ui.preferences.ExternalLibraryTreeContentProvider.java

@Override
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
    if (viewer instanceof TreeViewer) {
        this.treeViewerRef = Optional.of((TreeViewer) viewer);
    } else {//from   w w  w  .  ja va2  s. c  o  m
        this.treeViewerRef = Optional.absent();
    }
}

From source file:ninja.thymeleaf.template.TemplateEngineThymeleafI18nMessageResolver.java

@Override
public MessageResolution resolveMessage(Arguments arguments, String key, Object[] messageParameters) {
    Locale locale = null;//from w w  w  .  j  a v a2 s.co m
    if (arguments != null) {
        locale = arguments.getContext().getLocale();
    }

    Optional<String> lang = Optional.absent();
    if (locale != null) {
        // to conform to rfc5646 and BCP 47
        lang = Optional.of(locale.toString().replace('_', '-'));
    }

    Optional<String> i18nMessage = Optional.absent();
    i18nMessage = messages.get(key, lang, messageParameters);

    if (!i18nMessage.isPresent()) {
        return null;
    }

    return new MessageResolution(i18nMessage.or(""));
}