Package org.robolectric.res.android
Class NativeObjRegistry<T>
java.lang.Object
org.robolectric.res.android.NativeObjRegistry<T>
A unique id per object registry. Used to emulate android platform behavior of storing a long
which represents a pointer to an object.
-
Constructor Summary
ConstructorsConstructorDescriptionNativeObjRegistry(Class<T> theClass) NativeObjRegistry(Class<T> theClass, boolean debug) NativeObjRegistry(String name) NativeObjRegistry(String name, boolean debug) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()WARNING -- dangerous! Callunregister(long)instead!getNativeObject(long nativeId) Retrieve the native object for given id.longDeprecated.peekNativeObject(long nativeId) Similar togetNativeObject(long)but returns null if object with given id cannot be found.longRegister and assign a new unique native id for given object (representing a C memory pointer).unregister(long nativeId) Unregister an object previously registered withregister(Object).voidunregister(T removed) Deprecated.Useunregister(long)instead.voidUpdates the native object for the given id.
-
Constructor Details
-
NativeObjRegistry
-
NativeObjRegistry
-
NativeObjRegistry
-
NativeObjRegistry
-
-
Method Details
-
getNativeObjectId
Deprecated.Useregister(Object)instead.Retrieve the native id for given object. Assigns a new unique id to the object if not previously registered. -
register
Register and assign a new unique native id for given object (representing a C memory pointer).- Throws:
IllegalStateException- if the object was previously registered
-
unregister
Unregister an object previously registered withregister(Object).- Parameters:
nativeId- the unique id (representing a C memory pointer) of the object to unregister.- Throws:
IllegalStateException- if the object was never registered, or was previously unregistered.
-
unregister
Deprecated.Useunregister(long)instead. -
getNativeObject
Retrieve the native object for given id. Throws if object with that id cannot be found -
update
Updates the native object for the given id.- Throws:
IllegalStateException- if no object was registered with the given id before
-
peekNativeObject
Similar togetNativeObject(long)but returns null if object with given id cannot be found. -
clear
public void clear()WARNING -- dangerous! Callunregister(long)instead!
-
register(Object)instead.