org.openide.util.lookup

## Class ProxyLookup

- java.lang.Object
- - org.openide.util.Lookup
  - - org.openide.util.lookup.ProxyLookup

-     public class ProxyLookup
      extends Lookup

  Implementation of lookup that can delegate to others.
  Since:
    1.9
  Author:
    Jaroslav Tulach

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.openide.util.Lookup

      `Lookup.Item<T>, Lookup.Provider, Lookup.Result<T>, Lookup.Template<T>`

  - ### Field Summary

    - ### Fields inherited from class org.openide.util.Lookup

      `EMPTY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ProxyLookup()` Create a lookup initially proxying to no others.
    `` | `ProxyLookup(Lookup... lookups)` Create a proxy to some other lookups.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `beforeLookup(Lookup.Template<?> template)` Notifies subclasses that a query is about to be processed.
    `protected Lookup[]` | `getLookups()` Getter for the delegates.
    `<T> T` | `lookup(Class<T> clazz)` Look up an object matching a given interface.
    `<T> Lookup.Result<T>` | `lookup(Lookup.Template<T> template)` The general lookup method.
    `<T> Lookup.Item<T>` | `lookupItem(Lookup.Template<T> template)` Look up the first item matching a given template.
    `protected void` | `setLookups(Executor notifyIn, Lookup... lookups)` Changes the delegates immediatelly, notifies the listeners in provided executor, potentially later.
    `protected void` | `setLookups(Lookup... lookups)` Changes the delegates.
    `String` | `toString()` Returns a string representation of the object.

    - ### Methods inherited from class org.openide.util.Lookup

      `getDefault, lookupAll, lookupResult`

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

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

- - ### Constructor Detail

    - #### ProxyLookup

          public ProxyLookup(Lookup... lookups)

      Create a proxy to some other lookups.
      Parameters:
        `lookups` - the initial delegates

    - #### ProxyLookup

          protected ProxyLookup()

      Create a lookup initially proxying to no others. Permits serializable subclasses.
      Since:
        3.27

  - ### Method Detail

    - #### toString

          public String toString()

      Description copied from class: `Object`
      Returns a string representation of the object. In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

      The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

      >      getClass().getName() + '@' + Integer.toHexString(hashCode())

      Overrides:
        `toString` in class `Object`
      Returns:
        a string representation of the object.

    - #### getLookups

          protected final Lookup[] getLookups()

      Getter for the delegates.
      Returns:
        the array of lookups we delegate to
      Since:
        1.19

    - #### setLookups

          protected final void setLookups(Lookup... lookups)

      Changes the delegates.
      Parameters:
        `lookups` - the new lookups to delegate to
      Since:
        1.19 protected

    - #### setLookups

          protected final void setLookups(Executor notifyIn,
                                          Lookup... lookups)

      Changes the delegates immediatelly, notifies the listeners in provided executor, potentially later.
      Parameters:
        `lookups` - the new lookups to delegate to
        `notifyIn` - executor to deliver the notification to listeners or null
      Since:
        7.16

    - #### beforeLookup

          protected void beforeLookup(Lookup.Template<?> template)

      Notifies subclasses that a query is about to be processed. Subclasses can update its state before the actual processing begins. It is allowed to call `setLookups` method to change/update the set of objects the proxy delegates to.
      Parameters:
        `template` - the template of the query
      Since:
        1.31

    - #### lookup

          public final <T> T lookup(Class<T> clazz)

      Description copied from class: `Lookup`
      Look up an object matching a given interface. This is the simplest method to use. If more than one object matches, the first will be returned. The template class may be a class or interface; the instance is guaranteed to be assignable to it.
      Specified by:
        `lookup` in class `Lookup`
      Parameters:
        `clazz` - class of the object we are searching for
      Returns:
        an object implementing the given class or `null` if no such implementation is found

    - #### lookupItem

          public final <T> Lookup.Item<T> lookupItem(Lookup.Template<T> template)

      Description copied from class: `Lookup`
      Look up the first item matching a given template. Includes not only the instance but other associated information.
      Overrides:
        `lookupItem` in class `Lookup`
      Parameters:
        `template` - the template to check
      Returns:
        a matching item or `null`

    - #### lookup

          public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template)

      Description copied from class: `Lookup`
      The general lookup method. Callers can get list of all instances and classes that match the given `template`, request more info about them in form of `Lookup.Item` and attach a listener to this be notified about changes. The general interface does not specify whether subsequent calls with the same template produce new instance of the `Lookup.Result` or return shared instance. The prefered behaviour however is to return shared one.
      Specified by:
        `lookup` in class `Lookup`
      Parameters:
        `template` - a template describing the services to look for
      Returns:
        an object containing the results

Copyright © 2025 API Design. All Rights Reserved.