> + int maxTries = 100;
> + int currentTries = 0;
> + List<SshKey> keys = api.getKeyPairApi().list();
> +
> + while (currentTries < maxTries) {
> + final String name =
> namingConvention.create().uniqueNameForGroup("credentials");
> + if (!any(keys, new Predicate<SshKey>() {
> + @Override
> + public boolean apply(SshKey input) {
> + return name.equals(input.getName());
> + }
> +
> + })) {
> + key = api.getKeyPairApi().create(name,
> keyPair.get("public"));
> + break;
> + }
I'm a big functional fan in general, but this (to me, at least) feels much
harder to read than something like (see also the [Guava
page](https://code.google.com/p/guava-libraries/wiki/FunctionalExplained)):
```
boolean keyExists = false;
for (SshKey keys : keys) {
if (name.equals(key.getName()) {
keyExists = true;
break;
}
}
if (!keyExists) {
...
}
```
Do we expect significant gains from (potentially) running the `any` in parallel?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/49/files#r9151468