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

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

Introduction

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

Prototype

public static <T> Optional<T> absent() 

Source Link

Document

Returns an Optional instance with no contained reference.

Usage

From source file:org.immutables.fixture.OptionalCast.java

@SuppressWarnings("CheckReturnValue")
default void use() {
    ImmutableOptionalCast.of(Optional.absent(), Optional.of("String is object"), Optional.<String[]>absent(),
            Optional.absent());/*from w  w  w .  jav  a2 s . c  o m*/
}

From source file:extrabiomes.module.amica.ic2.IC2API.java

IC2API() {
    Class cls;/*from  w  w w .  ja v a  2 s.  c  o m*/
    try {
        cls = Class.forName("ic2.api.crops.Crops");
        ic2CropsInstance = cls.getField("instance").get(null);
        addBiomeBonus = Optional
                .fromNullable(cls.getMethod("addBiomeBonus", BiomeGenBase.class, Integer.TYPE, Integer.TYPE));
    } catch (final Exception e) {
        e.printStackTrace();
        addBiomeBonus = Optional.absent();
    }
}

From source file:org.everit.json.schema.internal.URIFormatValidator.java

@Override
public Optional<String> validate(final String subject) {
    try {/*from   ww  w .  ja v a  2 s.  co  m*/
        new URI(subject);
        return Optional.absent();
    } catch (URISyntaxException | NullPointerException e) {
        return Optional.of(String.format("[%s] is not a valid URI", subject));
    }
}

From source file:springfox.documentation.swagger.readers.parameter.ParameterAnnotationReader.java

private static Optional<Method> interfaceMethod(Class<?> iface, Method method) {
    try {//  www .ja v  a  2 s. c  o  m
        return Optional.of(iface.getMethod(method.getName(), method.getParameterTypes()));
    } catch (NoSuchMethodException ex) {
        return Optional.absent();
    }
}

From source file:org.onos.yangtools.yang.data.impl.schema.tree.AbstractDataTreeCandidateNode.java

private static Optional<NormalizedNode<?, ?>> getChild(
        final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> container,
        final PathArgument identifier) {
    if (container != null) {
        return container.getChild(identifier);
    } else {//from  w  w  w.j  a v a 2 s  .c o m
        return Optional.absent();
    }
}

From source file:com.github.rinde.rinsim.core.model.comm.AbstractBuilder.java

AbstractBuilder() {
    deviceReliability = 1d;
    deviceMaxRange = Optional.absent();
}

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

@Override
public Optional<UserPO> signin(String name, String password) {
    UserPO userPO = this.userDAO.findByName(name);
    if (userPO != null && userPO.getPassword().equals(password)) {
        return Optional.of(userPO);
    } else {/*from w  w w. ja v  a  2 s  .co m*/
        return Optional.absent();
    }
}

From source file:com.eucalyptus.util.FUtils.java

/**
 * Flatten a nested optional.//from www  .  ja v a2s .c  o  m
 *
 * @param option The optional to flatten
 * @param <T> The resulting optional type
 * @return The optional
 */
@Nonnull
public static <T> Optional<T> flatten(@Nullable final Optional<? extends Optional<T>> option) {
    if (option != null && option.isPresent()) {
        return option.get();
    }
    return Optional.absent();
}

From source file:com.qcadoo.mes.orders.dates.OrderDates.java

public static Optional<OrderDates> of(final Entity order) {
    if (hasPlannedDatesDefined(order)) {
        return Optional.of(OrderDates.of(order, Optional.<DateTime>absent(), Optional.<DateTime>absent()));
    } else {// w  ww .  j  a v  a 2 s  .  c om
        return Optional.absent();
    }
}

From source file:nl.ipsen3.service.AuthenticationService.java

@Override
public Optional<User> authenticate(BasicCredentials credentials) throws AuthenticationException {
    User user = userDAO.getByEmailAddress(credentials.getUsername());

    if (user != null && user.getPassword().equals(credentials.getPassword())) {
        return Optional.of(user);
    }//from w  ww .  j av a 2s  .com

    return Optional.absent();
}