MCPcopy Create free account
hub / github.com/MTrop/DoomTools / getObject

Method getObject

src/main/java/net/mtrop/doom/tools/struct/Loader.java:291–344  ·  view source on GitHub ↗

Get or load an object by name. The name is case-insensitive. @param name the name of the object. @return the corresponding loaded object, or null if not loaded.

(String name)

Source from the content-addressed store, hash-verified

289 * @return the corresponding loaded object, or null if not loaded.
290 */
291 public T getObject(String name)
292 {
293 if (errorNames.contains(name))
294 return null;
295 if (nameMap.containsKey(name))
296 return nameMap.get(name);
297
298 T object = null;
299
300 try
301 {
302 synchronized (uniqueKey(name))
303 {
304 // Early outs for waiting threads.
305 if (errorNames.contains(name))
306 return null;
307 if (nameMap.containsKey(name))
308 return nameMap.get(name);
309
310 for (int i = 0; i < loaderFunctions.length; i++)
311 {
312 try
313 {
314 if ((object = loaderFunctions[i].load(name)) != null)
315 break;
316 }
317 catch (Exception e)
318 {
319 if (errorListener != null)
320 errorListener.onLoaderError(loaderFunctions[i], e);
321 continue;
322 }
323 }
324 }
325 }
326 finally
327 {
328 releaseKey(name);
329 }
330
331 if (object == null)
332 {
333 synchronized (errorNames)
334 {
335 errorNames.add(name);
336 }
337 }
338 else
339 {
340 setObject(name, object);
341 }
342
343 return object;
344 }
345
346 /**
347 * Get or load an object by name asynchronously.

Callers 3

executeMethod · 0.80
getImageMethod · 0.80
getImageMethod · 0.80

Calls 7

uniqueKeyMethod · 0.95
releaseKeyMethod · 0.95
setObjectMethod · 0.95
onLoaderErrorMethod · 0.80
addMethod · 0.80
getMethod · 0.65
loadMethod · 0.65

Tested by

no test coverage detected