org.openide.util

## Class Lookup.Item<T>

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

- Direct Known Subclasses:
    AbstractLookup.Pair
  Enclosing class:
    Lookup

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

  A single item in a lookup result. This wrapper provides unified access to not just the instance, but its class, a possible persistent identifier, and so on.
  Since:
    1.25

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Item()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract String` | `getDisplayName()` Get a human presentable name for the item.
    `abstract String` | `getId()` Get a persistent identifier for the item.
    `abstract T` | `getInstance()` Get the instance itself.
    `abstract Class<? extends T>` | `getType()` Get the implementing class of the instance.
    `String` | `toString()` Returns a string representation of the object.

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

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

- - ### Constructor Detail

    - #### Item

          public Item()

  - ### Method Detail

    - #### getInstance

          public abstract T getInstance()

      Get the instance itself.
      Returns:
        the instance or null if the instance cannot be created

    - #### getType

          public abstract Class<? extends T> getType()

      Get the implementing class of the instance.
      Returns:
        the class of the item

    - #### getId

          public abstract String getId()

      Get a persistent identifier for the item. This identifier should uniquely represent the item within its containing lookup (and if possible within the global lookup as a whole). For example, it might represent the source of the instance as a file name. The ID may be persisted and in a later session used to find the same instance as was encountered earlier, by means of passing it into a lookup template.
      Returns:
        a string ID of the item

    - #### getDisplayName

          public abstract String getDisplayName()

      Get a human presentable name for the item. This might be used when summarizing all the items found in a lookup result in some part of a GUI.
      Returns:
        the string suitable for presenting the object to a user

    - #### 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.

Copyright © 2025 API Design. All Rights Reserved.