I am new to Corda and am designing a Cordap. I want to display the states onto the terminal based on some arguments passed during initiating the flow. My approach was I created a List of type StateAndRef storing all the states. Now I loop through the list and display the state based on if else condition.
But the issue I am facing is somethimes all the states the printed and sometimes only few of them are printed. Please help me to solve this problem. My main motive is I should be able to display on the screen those states which have name Car.
PS: I am using Java for designing the Cordapp.
You don't really need a flow to display states. You con using vaultQuery to do so:
Refer documentation here for: https://docs.corda.net/docs/corda-os/4.4/shell.html#examples
In case you want to do complex querying, it's not supported in the CRaSH shell. However, you could do so in the RPC Client using the vault Query API. The VaultQuery API is very flexible and provide a number of mechanisms to access the vault.
Check the documentation here: https://docs.corda.net/docs/corda-os/4.4/api-vault-query.html#api-vault-query