All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.util.Optionals Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
package io.dropwizard.util;

import java.util.Optional;

public abstract class Optionals {
    /**
     * Convert a Guava {@link com.google.common.base.Optional} to an {@link Optional}.
     *
     * @param guavaOptional The Guava {@link com.google.common.base.Optional}
     * @return An equivalent {@link Optional}
     */
    public static  Optional fromGuavaOptional(final com.google.common.base.Optional guavaOptional) {
        return Optional.ofNullable(guavaOptional.orNull());
    }

    /**
     * Convert an {@link Optional} to a Guava {@link com.google.common.base.Optional}.
     *
     * @param optional The {@link Optional}
     * @return An equivalent Guava {@link com.google.common.base.Optional}
     */
    public static  com.google.common.base.Optional toGuavaOptional(final Optional optional) {
        return com.google.common.base.Optional.fromNullable(optional.orElse(null));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy