Quick Hotbar Question

I’m working with inventories, and I’m using the following code to get a hotbar:

Hotbar hotbar = inventory.query(Hotbar.class);

The documentation for query states:

org.spongepowered.api.item.inventory.Inventory
    public abstract <T extends Inventory> T query(java.lang.Class<?>... types)
        Query this inventory for inventories matching any of the supplied types. This is effectively an instanceof check against each child inventory. Logical OR is applied between operands.
Parameters:
    types - inventory types (interfaces or classes) to query for
Returns:
    the query result

My question is, what happens if there is no matching child inventory? As in, what if I’m trying to get a hotbar from a chest’s inventory, what does this method return then?

I did a quick scan of @mumfrey’s original API PR (#443) and found this:

The main idea of queries is that given an unknown Inventory instance, it should be possible to query for any sub-inventory or combination of matching sub-inventories, with the query returning either all sub-inventories which match the query, or an empty set if no sub-inventories matched the query.

So I assume this means that it would return the EmptyInventory if it wasn’t found, but because of the duck-typing it would throw a ClassCastException as it can’t cast EmptyInventory to Hotbar.
So perhaps just do Inventory hotbar = inventory.query(Hotbar.class); then check hotbar instanceof Hotbar

Okay! Thanks for the help.