org.openide.util

## Class Lookup.Result<T>

- java.lang.Object
- - org.openide.util.Lookup.Result<T>

- Enclosing class:
    Lookup

      public abstract static class Lookup.Result<T>
      extends Object

  Result of a lookup request. Allows access to all matching instances at once. Also permits listening to changes in the result. Result can contain duplicate items.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Result()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addLookupListener(LookupListener l)` Registers a listener that is invoked when there is a possible change in this result.
    `Set<Class<? extends T>>` | `allClasses()` Get all classes represented in the result.
    `abstract Collection<? extends T>` | `allInstances()` Get all instances in the result.
    `Collection<? extends Lookup.Item<T>>` | `allItems()` Get all registered items.
    `abstract void` | `removeLookupListener(LookupListener l)` Unregisters a listener previously added.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Result

          public Result()

  - ### Method Detail

    - #### addLookupListener

          public abstract void addLookupListener(LookupListener l)

      Registers a listener that is invoked when there is a possible change in this result.

      Sometimes people report that their listener is not receiving events (for example IZ 191471) or that the listener receives few events, but then it stops listening. Such behavior is often caused by not keeping strong reference to the `Lookup.Result` object. When it gets garbage collected it can no longer deliver events. Thus remember to keep reference to the object you are attaching listener to.
      Parameters:
        `l` - the listener to add

    - #### removeLookupListener

          public abstract void removeLookupListener(LookupListener l)

      Unregisters a listener previously added.
      Parameters:
        `l` - the listener to remove

    - #### allInstances

          public abstract Collection<? extends T> allInstances()

      Get all instances in the result. The return value is an unmodifiable list (hence the type should be `List` as the order matters, but the `Collection` is kept for compatibility reasons) of all instances present in the `Lookup.Result` right now that will never change its content.

      While the returned collection never changes its content, some implementation like `ProxyLookup` may compute the content lazily. At least once such behavior resulted in a deadlock.
      Returns:
        unmodifiable collection of all instances that will never change its content

    - #### allClasses

          public Set<Class<? extends T>> allClasses()

      Get all classes represented in the result. That is, the set of concrete classes used by instances present in the result. All duplicate classes will be omitted.
      Returns:
        unmodifiable set of `Class` objects that will never change its content
      Since:
        1.8

    - #### allItems

          public Collection<? extends Lookup.Item<T>> allItems()

      Get all registered items. This includes all pairs of instances together with their classes, `IDs`, and so on. The return value is an unmodifiable list (hence the type should be `List` as the order matters, but the `Collection` is kept for compatibility reasons) of all `items` present in the `Lookup.Result` right now that will never change its content.

      While the returned collection never changes its content, some implementation like `ProxyLookup` may compute the content lazily.
      Returns:
        unmodifiable collection of `Lookup.Item` that will never change its content
      Since:
        1.8

Copyright © 2025 API Design. All Rights Reserved.