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

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

Introduction

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

Prototype

public static <T> Optional<T> fromNullable(@Nullable T nullableReference) 

Source Link

Document

If nullableReference is non-null, returns an Optional instance containing that reference; otherwise returns Optional#absent .

Usage

From source file:de.brands4friends.daleq.core.ImmutableFieldData.java

public ImmutableFieldData(final String name, @Nullable final String value) {
    this.name = Preconditions.checkNotNull(name);
    this.value = Optional.fromNullable(value);
}

From source file:im.dadoo.teak.biz.bo.impl.DefaultLinkBO.java

@Override
public Optional<LinkPO> insert(String name, String url, String description) {
    LinkPO linkPO = new LinkPO();
    linkPO.setName(name);/*from w  w w  .  ja  v a2s.  c om*/
    linkPO.setUrl(url);
    linkPO.setDescription(description);
    return Optional.fromNullable(this.linkDAO.insert(linkPO));
}

From source file:com.google.cloud.tools.intellij.DefaultApplicationPluginInfoService.java

@Override
public Optional<IdeaPluginDescriptor> findPlugin(String pluginId) {
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.findId(pluginId));
    return Optional.fromNullable(plugin);
}

From source file:org.basepom.mojo.propertyhelper.beans.DateDefinition.java

public Optional<String> getTimezone() {
    return Optional.fromNullable(timezone);
}

From source file:org.terasology.cities.model.SimpleLot.java

/**
 * @param fence the fence to set (or <code>null</code> to clear)
 *///from   w  w  w . j  ava 2  s.com
public void setFence(SimpleFence fence) {
    this.fence = Optional.fromNullable(fence);
}

From source file:springfox.documentation.schema.Annotations.java

public static boolean memberIsUnwrapped(AnnotatedMember member) {
    if (member == null) {
        return false;
    }// ww  w  . jav  a 2s.  c  o  m
    return Optional.fromNullable(member.getAnnotation(JsonUnwrapped.class)).isPresent();
}

From source file:org.raml.jaxrs.handlers.FieldAnnotable.java

@Override
public <T extends Annotation> Optional<T> getAnnotation(Class<T> annotationType) {
    return Optional.fromNullable(field.getAnnotation(annotationType));
}

From source file:org.raml.jaxrs.handlers.MethodAnnotable.java

@Override
public <T extends Annotation> Optional<T> getAnnotation(Class<T> annotationType) {
    return Optional.fromNullable(method.getAnnotation(annotationType));
}

From source file:org.geogit.api.RevFeatureBuilder.java

/**
 * Constructs a new {@link RevFeature} from the provided {@link Feature}.
 * /*  w w  w  . ja  v a2 s.c  o  m*/
 * @param feature the feature to build from
 * @return the newly constructed RevFeature
 */
public RevFeature build(Feature feature) {
    if (feature == null) {
        throw new IllegalStateException("No feature set");
    }

    Collection<Property> props = feature.getProperties();

    ImmutableList.Builder<Optional<Object>> valuesBuilder = new ImmutableList.Builder<Optional<Object>>();

    for (Property prop : props) {
        valuesBuilder.add(Optional.fromNullable(prop.getValue()));
    }

    return RevFeature.build(valuesBuilder.build());
}

From source file:org.eclipse.che.plugin.languageserver.ide.editor.signature.ParamterInfoImpl.java

@Override
public Optional<String> getDocumentation() {
    return Optional.fromNullable(dto.getDocumentation());
}