Class OwnedOrExternal<T>

java.lang.Object
com.couchbase.client.core.env.OwnedOrExternal<T>

@Internal public class OwnedOrExternal<T> extends Object
A holder for a resource that is either "owned" (created and managed by the SDK) or "external" (created and managed outside the SDK).

Note: Although this class bears a passing resemblance to Supplier, it has different semantics. Unlike Supplier.get(), this class's get() method is guaranteed to return the same instance every time.

  • Method Details

    • owned

      public static <T> OwnedOrExternal<T> owned(T resource)
    • external

      public static <T> OwnedOrExternal<T> external(T resource)
    • isOwned

      public boolean isOwned()
      Returns true if the resource is managed by the SDK, otherwise false.
    • get

      public T get()
      Returns the resource.
    • toString

      public String toString()
      Overrides:
      toString in class Object