Skip to content

Instantly share code, notes, and snippets.

@MwBakker
Created June 6, 2019 12:48
Show Gist options
  • Save MwBakker/0cbc015566bc4432a477452eb5cb518b to your computer and use it in GitHub Desktop.
Save MwBakker/0cbc015566bc4432a477452eb5cb518b to your computer and use it in GitHub Desktop.
// manually sets the storage to storageUI
private List<UIStorage> createStorageUIList(List<Storage> storageUnits, Executor executor)
{
List<UIStorage> UIStorageList = new ArrayList<>();
for (Storage storage : storageUnits)
{
executor.execute(() ->
{
UIStorageList.add(createUIStorage(storage));
});
}
return UIStorageList;
}
// returns one storage unit
public UIStorage getUIStorageUnit(long id)
{
return createUIStorage(getDao().getStorageUnit(id));
}
// returns uiStorage from storage
private UIStorage createUIStorage(Storage storage)
{
UIStorage uiStorage = new UIStorage(storage.id, storage.getName(), storage.getLocation(), storage.getImgPath());
uiStorage.setAmountOfRacks(getDao().getAmountOfRacks(storage.id));
uiStorage.setAmountOfComponents(getDao().getAmountOfComponents(storage.id));
return uiStorage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment