Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 288 for toOptional (0.04 sec)

  1. android/guava/src/com/google/common/collect/MoreCollectors.java

       * @return {@code Optional.of(onlyElement)} if the stream has exactly one element (must not be
       *     {@code null}) and returns {@code Optional.empty()} if it has none.
       */
      @SuppressWarnings("unchecked")
      public static <T> Collector<T, ?, Optional<T>> toOptional() {
        return (Collector) TO_OPTIONAL;
      }
    
      private static final Object NULL_PLACEHOLDER = new Object();
    
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Mon Apr 14 16:07:06 UTC 2025
    - 5.6K bytes
    - Viewed (0)
  2. guava/src/com/google/common/collect/MoreCollectors.java

       * @return {@code Optional.of(onlyElement)} if the stream has exactly one element (must not be
       *     {@code null}) and returns {@code Optional.empty()} if it has none.
       */
      @SuppressWarnings("unchecked")
      public static <T> Collector<T, ?, Optional<T>> toOptional() {
        return (Collector) TO_OPTIONAL;
      }
    
      private static final Object NULL_PLACEHOLDER = new Object();
    
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Sat Apr 12 15:07:59 UTC 2025
    - 5.4K bytes
    - Viewed (0)
  3. android/guava/src/com/google/common/collect/Iterables.java

       * iterable is empty.
       *
       * <p><b>Java 8+ users:</b> the {@code Stream} equivalent to this method is {@code
       * stream.collect(MoreCollectors.toOptional()).orElse(defaultValue)}.
       *
       * @throws IllegalArgumentException if the iterator contains multiple elements
       */
      @ParametricNullness
      public static <T extends @Nullable Object> T getOnlyElement(
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Thu Aug 07 16:05:33 UTC 2025
    - 43.6K bytes
    - Viewed (0)
  4. guava/src/com/google/common/collect/Iterables.java

       * iterable is empty.
       *
       * <p><b>Java 8+ users:</b> the {@code Stream} equivalent to this method is {@code
       * stream.collect(MoreCollectors.toOptional()).orElse(defaultValue)}.
       *
       * @throws IllegalArgumentException if the iterator contains multiple elements
       */
      @ParametricNullness
      public static <T extends @Nullable Object> T getOnlyElement(
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Thu Aug 07 16:05:33 UTC 2025
    - 43.3K bytes
    - Viewed (0)
  5. android/guava/src/com/google/common/base/Present.java

      @Override
      public T get() {
        return reference;
      }
    
      @Override
      public T or(T defaultValue) {
        checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)");
        return reference;
      }
    
      @Override
      public Optional<T> or(Optional<? extends T> secondChoice) {
        checkNotNull(secondChoice);
        return this;
      }
    
      @Override
      public T or(Supplier<? extends T> supplier) {
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Tue Apr 15 22:14:00 UTC 2025
    - 2.5K bytes
    - Viewed (0)
  6. android/guava/src/com/google/common/collect/Streams.java

       *
       * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
       */
      @Beta
      @InlineMe(replacement = "optional.stream()")
      @InlineMeValidationDisabled("Java 9+ API only")
      public static <T> Stream<T> stream(java.util.Optional<T> optional) {
        return optional.isPresent() ? Stream.of(optional.get()) : Stream.empty();
      }
    
      /**
       * If a value is present in {@code optional}, returns a stream containing only that element,
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Sat Aug 09 01:14:59 UTC 2025
    - 37K bytes
    - Viewed (0)
  7. android/guava/src/com/google/common/base/Absent.java

        throw new IllegalStateException("Optional.get() cannot be called on an absent value");
      }
    
      @Override
      public T or(T defaultValue) {
        return checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)");
      }
    
      @SuppressWarnings("unchecked") // safe covariant cast
      @Override
      public Optional<T> or(Optional<? extends T> secondChoice) {
        return (Optional<T>) checkNotNull(secondChoice);
      }
    
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Tue Apr 15 22:14:00 UTC 2025
    - 2.6K bytes
    - Viewed (0)
  8. android/guava-tests/test/com/google/common/collect/ComparatorsTest.java

      public void testEmptiesFirst() {
        Optional<String> empty = Optional.empty();
        Optional<String> abc = Optional.of("abc");
        Optional<String> z = Optional.of("z");
    
        Comparator<Optional<String>> comparator = emptiesFirst(comparing(String::length));
        testComparator(comparator, empty, z, abc);
    
        // Just demonstrate that no explicit type parameter is required
        Comparator<Optional<String>> unused = emptiesFirst(naturalOrder());
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Sat Apr 12 15:07:59 UTC 2025
    - 6.4K bytes
    - Viewed (0)
  9. guava/src/com/google/common/collect/Comparators.java

        checkNotNull(valueComparator);
        return Comparator.<Optional<T>, @Nullable T>comparing(
            o -> orElseNull(o), Comparator.nullsLast(valueComparator));
      }
    
      // For discussion of why this exists, see the Android flavor.
      private static <T> @Nullable T orElseNull(Optional<T> optional) {
        return optional.orElse(null);
      }
    
      /**
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Mon Mar 17 20:26:29 UTC 2025
    - 10.9K bytes
    - Viewed (0)
  10. android/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java

      }
    
      private static final Function<Object, Optional<?>> NULLABLE_TO_OPTIONAL =
          new Function<Object, Optional<?>>() {
            @Override
            public Optional<?> apply(@Nullable Object obj) {
              return Optional.fromNullable(obj);
            }
          };
    
      private static final Function<Optional<?>, @Nullable Object> OPTIONAL_TO_NULLABLE =
          new Function<Optional<?>, @Nullable Object>() {
            @Override
    Registered: Fri Sep 05 12:43:10 UTC 2025
    - Last Modified: Tue Jul 08 18:32:10 UTC 2025
    - 8.4K bytes
    - Viewed (0)
Back to top