Package org.sosy_lab.common
Class Optionals
- java.lang.Object
-
- org.sosy_lab.common.Optionals
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> ImmutableSet<T>
asSet(Optional<T> optional)
Return a set that is either empty or contains the present instance of theOptional
.static <T> Stream<T>
asStream(Optional<T> optional)
Deprecated.static Ordering<OptionalDouble>
comparingDoubleEmptyFirst()
Return aOrdering
forOptionalDouble
that compares empty optionals as smaller than all non-empty instances, and compares present doubles using their natural order.static Ordering<OptionalDouble>
comparingDoubleEmptyLast()
Return aOrdering
forOptionalDouble
that compares empty optionals as larger than all non-empty instances, and compares present doubles using their natural order.static <T extends Comparable<T>>
Comparator<Optional<T>>comparingEmptyFirst()
Deprecated.static <T> Comparator<Optional<T>>
comparingEmptyFirst(Comparator<T> comparator)
Deprecated.static <T extends Comparable<T>>
Comparator<Optional<T>>comparingEmptyLast()
Deprecated.static <T> Comparator<Optional<T>>
comparingEmptyLast(Comparator<T> comparator)
Deprecated.static Ordering<OptionalInt>
comparingIntEmptyFirst()
Return aOrdering
forOptionalInt
that compares empty optionals as smaller than all non-empty instances, and compares present integers using their natural order.static Ordering<OptionalInt>
comparingIntEmptyLast()
Return aOrdering
forOptionalInt
that compares empty optionals as larger than all non-empty instances, and compares present integers using their natural order.static Ordering<OptionalLong>
comparingLongEmptyFirst()
Return aOrdering
forOptionalLong
that compares empty optionals as smaller than all non-empty instances, and compares present longs using their natural order.static Ordering<OptionalLong>
comparingLongEmptyLast()
Return aOrdering
forOptionalLong
that compares empty optionals as larger than all non-empty instances, and compares present longs using their natural order.static <T> Optional<T>
fromGuavaOptional(Optional<T> optional)
Deprecated.static DoubleStream
presentDoubles(Stream<OptionalDouble> stream)
Get aDoubleStream
of the present doubles of a stream ofOptionalDouble
s.static <T> FluentIterable<T>
presentInstances(Iterable<Optional<T>> iterable)
static <T> Stream<T>
presentInstances(Stream<Optional<T>> stream)
static IntStream
presentInts(Stream<OptionalInt> stream)
Get aIntStream
of the present integers of a stream ofOptionalInt
s.static LongStream
presentLongs(Stream<OptionalLong> stream)
Get aLongStream
of the present longs of a stream ofOptionalLong
s.static <T> Optional<T>
toGuavaOptional(Optional<T> optional)
Deprecated.
-
-
-
Method Detail
-
toGuavaOptional
@Deprecated @InlineMe(replacement="com.google.common.base.Optional.fromJavaUtil(checkNotNull(optional))", staticImports="com.google.common.base.Preconditions.checkNotNull") public static <T> Optional<T> toGuavaOptional(Optional<T> optional)
Deprecated.
-
fromGuavaOptional
@Deprecated @InlineMe(replacement="optional.toJavaUtil()") public static <T> Optional<T> fromGuavaOptional(Optional<T> optional)
Deprecated.
-
asSet
public static <T> ImmutableSet<T> asSet(Optional<T> optional)
Return a set that is either empty or contains the present instance of theOptional
.Can be used with
FluentIterable.transformAndConcat(com.google.common.base.Function)
to project anIterable
to the present instances. However, usingpresentInstances(Iterable)
would be more efficient.- Parameters:
optional
- An Optional.- Returns:
- A set with size at most one.
-
asStream
@Deprecated @InlineMe(replacement="optional.stream()") public static <T> Stream<T> asStream(Optional<T> optional)
Deprecated.Return a stream that is either empty or contains the present instance of the optional.Can be used with
Stream.flatMap(java.util.function.Function)
to project a stream to the present instances. However, usingpresentInstances(Stream)
would be more efficient.- Parameters:
optional
- An Optional.- Returns:
- A stream with size at most one.
-
presentInstances
public static <T> FluentIterable<T> presentInstances(Iterable<Optional<T>> iterable)
-
presentInts
public static IntStream presentInts(Stream<OptionalInt> stream)
Get aIntStream
of the present integers of a stream ofOptionalInt
s.
-
presentLongs
public static LongStream presentLongs(Stream<OptionalLong> stream)
Get aLongStream
of the present longs of a stream ofOptionalLong
s.
-
presentDoubles
public static DoubleStream presentDoubles(Stream<OptionalDouble> stream)
Get aDoubleStream
of the present doubles of a stream ofOptionalDouble
s.
-
comparingEmptyFirst
@Deprecated @InlineMe(replacement="Comparators.emptiesFirst(Comparator.<T>naturalOrder())", imports={"com.google.common.collect.Comparators","java.util.Comparator"}) public static <T extends Comparable<T>> Comparator<Optional<T>> comparingEmptyFirst()
Deprecated.
-
comparingEmptyFirst
@Deprecated @InlineMe(replacement="Comparators.emptiesFirst(comparator)", imports="com.google.common.collect.Comparators") public static <T> Comparator<Optional<T>> comparingEmptyFirst(Comparator<T> comparator)
Deprecated.
-
comparingEmptyLast
@Deprecated @InlineMe(replacement="Comparators.emptiesLast(Comparator.<T>naturalOrder())", imports={"com.google.common.collect.Comparators","java.util.Comparator"}) public static <T extends Comparable<T>> Comparator<Optional<T>> comparingEmptyLast()
Deprecated.
-
comparingEmptyLast
@Deprecated @InlineMe(replacement="Comparators.emptiesLast(comparator)", imports="com.google.common.collect.Comparators") public static <T> Comparator<Optional<T>> comparingEmptyLast(Comparator<T> comparator)
Deprecated.
-
comparingIntEmptyFirst
public static Ordering<OptionalInt> comparingIntEmptyFirst()
Return aOrdering
forOptionalInt
that compares empty optionals as smaller than all non-empty instances, and compares present integers using their natural order.
-
comparingIntEmptyLast
public static Ordering<OptionalInt> comparingIntEmptyLast()
Return aOrdering
forOptionalInt
that compares empty optionals as larger than all non-empty instances, and compares present integers using their natural order.
-
comparingLongEmptyFirst
public static Ordering<OptionalLong> comparingLongEmptyFirst()
Return aOrdering
forOptionalLong
that compares empty optionals as smaller than all non-empty instances, and compares present longs using their natural order.
-
comparingLongEmptyLast
public static Ordering<OptionalLong> comparingLongEmptyLast()
Return aOrdering
forOptionalLong
that compares empty optionals as larger than all non-empty instances, and compares present longs using their natural order.
-
comparingDoubleEmptyFirst
public static Ordering<OptionalDouble> comparingDoubleEmptyFirst()
Return aOrdering
forOptionalDouble
that compares empty optionals as smaller than all non-empty instances, and compares present doubles using their natural order.
-
comparingDoubleEmptyLast
public static Ordering<OptionalDouble> comparingDoubleEmptyLast()
Return aOrdering
forOptionalDouble
that compares empty optionals as larger than all non-empty instances, and compares present doubles using their natural order.
-
-