use of com.icodici.universa.contract.permissions.SplitJoinPermission in project universa by UniversaBlockchain.
the class Wallet method determineWallets.
public static List<Wallet> determineWallets(List<Contract> contracts) {
Map<Object, Wallet> wallets = new HashMap<>();
for (Contract contract : contracts) {
if (contract.getPermissions() == null)
continue;
Collection<Permission> splitJoinCollection = contract.getPermissions().get("split_join");
if (splitJoinCollection == null || splitJoinCollection.size() == 0)
continue;
Object split_join = splitJoinCollection.toArray()[0];
if (!(split_join instanceof SplitJoinPermission))
continue;
Object join_match_fields = ((SplitJoinPermission) split_join).getParams().get("join_match_fields");
Object field;
if (join_match_fields instanceof List)
field = ((List) join_match_fields).get(0);
else
field = join_match_fields;
Wallet wallet = wallets.get(field);
if (wallet == null) {
wallet = new Wallet();
}
wallet.addContract(contract);
wallets.put(field, wallet);
}
return new ArrayList<>(wallets.values());
}
Aggregations