public abstract class AssetLibrary<Key,Asset>
extends java.lang.Object
implements java.lang.Iterable<java.util.Map.Entry<Key,Asset>>
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<Key,Asset> |
entries |
| Modifier | Constructor and Description |
|---|---|
|
AssetLibrary(boolean concurrent) |
protected |
AssetLibrary(boolean concurrent,
boolean soft)
Constructor using the specified map for internal storage
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Key assetKey,
Asset asset)
Add an asset to the library.
|
java.lang.Iterable<Asset> |
assets() |
void |
clear() |
boolean |
contains(Key assetKey) |
Asset |
get(Key key)
Request an asset from its key
|
Key |
getKey(Asset asset)
Find the key associated to the asset
|
Asset |
getOrCreate(Key key,
java.util.function.Supplier<Asset> creator)
Request an asset from its key
|
java.util.Iterator<java.util.Map.Entry<Key,Asset>> |
iterator() |
Asset |
remove(Key assetKey) |
Key |
removeValue(Asset asset) |
int |
size() |
public AssetLibrary(boolean concurrent)
concurrent - true to use a concurrent collectionprotected AssetLibrary(boolean concurrent,
boolean soft)
public void add(Key assetKey, Asset asset) throws java.lang.IllegalArgumentException
asset - asset to store in the libraryassetKey - asset key, usually the loading informationjava.lang.IllegalArgumentException - when the asset is already in the librarypublic final Asset get(Key key)
key - asset keypublic final Asset getOrCreate(Key key, java.util.function.Supplier<Asset> creator)
key - asset keypublic final Key getKey(Asset asset)
asset - asset to findpublic final Asset remove(Key assetKey)
assetKey - the asset key to removepublic final Key removeValue(Asset asset)
asset - the asset to removepublic void clear()
public final boolean contains(Key assetKey)
public final int size()
public final java.lang.Iterable<Asset> assets()
Bonzai Engine 1.4.1-20200831 - A Java OpenGL engine and tools for Windows/Mac/Linux/Android
Copyright © 2007-2019 Jérôme Jouvie bonzaiengine.com contact@bonzaiengine.com