Package org.freedesktop.wayland.util
Class ObjectCache
java.lang.Object
org.freedesktop.wayland.util.ObjectCache
A cache for POJOs with a native context.
It maps POJOs to their native context (a native pointer) so it can consistently return the same POJO given a pointer
value.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
from
(MemorySegment pointer) Retrieve a POJO that is mapped to a native pointer.static <T> T
remove
(MemorySegment pointer) Remove a mapped POJO.static void
store
(MemorySegment pointer, Object object) Maps a native pointer to a POJO.
-
Constructor Details
-
ObjectCache
public ObjectCache()
-
-
Method Details
-
from
Retrieve a POJO that is mapped to a native pointer. This method should be used to easily retrieve a POJO with a native context. This method will only return a POJO if it was previously cached with a call tostore(MemorySegment, Object)
- Type Parameters:
T
- The type of the POJO to cast.- Parameters:
pointer
- The pointer of the associated object.- Returns:
- The cached object.
-
store
Maps a native pointer to a POJO. This method should be used to easily store a POJO with a native context.- Parameters:
pointer
- The pointer of the associated object.object
- The object to cache.
-
remove
Remove a mapped POJO. This method should be used when the native context of the POJO is no longer valid.- Parameters:
pointer
- The pointer of the associated object.
-