Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 962 for toOptional (0.22 sec)

  1. guava-tests/test/com/google/common/collect/MoreCollectorsTest.java

        assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
      }
    
      public void testToOptionalSingleton() {
        assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
      }
    
      public void testToOptionalNull() {
        Stream<@Nullable Object> stream = Stream.of((Object) null);
        try {
          stream.collect(MoreCollectors.toOptional());
          fail("Expected NullPointerException");
    Java
    - Registered: Fri Apr 19 12:43:09 GMT 2024
    - Last Modified: Thu Mar 07 18:34:03 GMT 2024
    - 3.4K bytes
    - Viewed (0)
  2. 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();
    
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Wed May 01 18:44:57 GMT 2024
    - 5.7K 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(
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Wed Apr 24 19:38:27 GMT 2024
    - 42.8K 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(
    Java
    - Registered: Fri Apr 05 12:43:09 GMT 2024
    - Last Modified: Thu Feb 15 16:12:13 GMT 2024
    - 42.5K bytes
    - Viewed (0)
  5. guava/src/com/google/common/base/Optional.java

     */
    @DoNotMock("Use Optional.of(value) or Optional.absent()")
    @GwtCompatible(serializable = true)
    @ElementTypesAreNonnullByDefault
    public abstract class Optional<T> implements Serializable {
      /**
       * Returns an {@code Optional} instance with no contained reference.
       *
       * <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
       * {@code Optional.empty}.
       */
      public static <T> Optional<T> absent() {
    Java
    - Registered: Fri Apr 05 12:43:09 GMT 2024
    - Last Modified: Mon Apr 01 16:15:01 GMT 2024
    - 14.6K bytes
    - Viewed (0)
  6. android/guava/src/com/google/common/base/Optional.java

     */
    @DoNotMock("Use Optional.of(value) or Optional.absent()")
    @GwtCompatible(serializable = true)
    @ElementTypesAreNonnullByDefault
    public abstract class Optional<T> implements Serializable {
      /**
       * Returns an {@code Optional} instance with no contained reference.
       *
       * <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
       * {@code Optional.empty}.
       */
      public static <T> Optional<T> absent() {
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Mon Apr 01 16:15:01 GMT 2024
    - 13K bytes
    - Viewed (0)
  7. tests/test_security_http_bearer_optional.py

    from typing import Optional
    
    from fastapi import FastAPI, Security
    from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    security = HTTPBearer(auto_error=False)
    
    
    @app.get("/users/me")
    def read_current_user(
        credentials: Optional[HTTPAuthorizationCredentials] = Security(security),
    ):
        if credentials is None:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  8. tests/test_security_http_digest_optional.py

    from typing import Optional
    
    from fastapi import FastAPI, Security
    from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    security = HTTPDigest(auto_error=False)
    
    
    @app.get("/users/me")
    def read_current_user(
        credentials: Optional[HTTPAuthorizationCredentials] = Security(security),
    ):
        if credentials is None:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.2K bytes
    - Viewed (0)
  9. tests/test_security_openid_connect_optional.py

    from typing import Optional
    
    from fastapi import Depends, FastAPI, Security
    from fastapi.security.open_id_connect_url import OpenIdConnect
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    oid = OpenIdConnect(openIdConnectUrl="/openid", auto_error=False)
    
    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: Optional[str] = Security(oid)):
        if oauth_header is None:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.4K bytes
    - Viewed (0)
  10. tests/test_security_oauth2_optional.py

    
    def get_current_user(oauth_header: Optional[str] = Security(reusable_oauth2)):
        if oauth_header is None:
            return None
        user = User(username=oauth_header)
        return user
    
    
    @app.post("/login")
    def login(form_data: OAuth2PasswordRequestFormStrict = Depends()):
        return form_data
    
    
    @app.get("/users/me")
    def read_users_me(current_user: Optional[User] = Depends(get_current_user)):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 10.8K bytes
    - Viewed (0)
Back to top