mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-09 04:09:43 +01:00
Don't throw an exception the first time we initialize IntHashMap.
This commit is contained in:
parent
fc01a61290
commit
8295b951d9
@ -98,9 +98,25 @@ public class WrappedIntHashMap {
|
||||
* @return The object that was removed, or NULL if the key is not present.
|
||||
*/
|
||||
public Object remove(int key) {
|
||||
initializeGetMethod();
|
||||
|
||||
if (REMOVE_METHOD == null)
|
||||
return removeFallback(key);
|
||||
return invokeMethod(REMOVE_METHOD, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a entry in the IntHashMap using a fallback method.
|
||||
* @param key - the key of the mapping to remove.
|
||||
* @return The removed element.
|
||||
*/
|
||||
private Object removeFallback(int key) {
|
||||
Object old = get(key);
|
||||
|
||||
invokeMethod(PUT_METHOD, key, null);
|
||||
return old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke a particular method on the current handle
|
||||
* @param method - the current method.
|
||||
@ -162,7 +178,9 @@ public class WrappedIntHashMap {
|
||||
// Suppress
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unable to find appropriate GET_METHOD for IntHashMap.");
|
||||
|
||||
if (GET_METHOD == null)
|
||||
throw new IllegalStateException("Unable to find appropriate GET_METHOD for IntHashMap.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user