class BusinessObjectDataHelper {

    public StorageUnit getStorageUnitByStorageName(BusinessObjectData businessObjectData, String storageName) throws IllegalStateException
    {
        StorageUnit resultStorageUnit = null;

        // Find a storage unit that belongs to the specified storage.
        for (StorageUnit storageUnit : businessObjectData.getStorageUnits())
        {
            if (storageUnit.getStorage().getName().equalsIgnoreCase(storageName))
            {
                resultStorageUnit = storageUnit;
                break;
            }
        }

        // Validate that we found a storage unit that belongs to the specified storage.
        if (resultStorageUnit == null)
        {
            throw new IllegalStateException(String.format("Business object data has no storage unit with storage name \"%s\".", storageName));
        }

        return resultStorageUnit;
    }

}