Refactor isRegistered

This commit is contained in:
AsamK 2021-09-26 20:16:27 +02:00
parent 1c4a32fef4
commit 375c9d60cf

View file

@ -468,8 +468,7 @@ public class DbusSignalImpl implements Signal {
@Override @Override
public boolean isRegistered() { public boolean isRegistered() {
var result = isRegistered(List.of(m.getUsername())); return true;
return result.get(0);
} }
@Override @Override
@ -480,21 +479,22 @@ public class DbusSignalImpl implements Signal {
@Override @Override
public List<Boolean> isRegistered(List<String> numbers) { public List<Boolean> isRegistered(List<String> numbers) {
var results = new ArrayList<Boolean> (); var results = new ArrayList<Boolean>();
Map<String, Pair<String, UUID>> registered;
if (numbers.isEmpty()) { if (numbers.isEmpty()) {
return results; return results;
} }
Map<String, Pair<String, UUID>> registered;
try { try {
registered = m.areUsersRegistered(new HashSet<String>(numbers)); registered = m.areUsersRegistered(new HashSet<>(numbers));
} catch (IOException e) { } catch (IOException e) {
throw new Error.Failure(e.getMessage()); throw new Error.Failure(e.getMessage());
} }
for (String number : numbers) {
UUID uuid = registered.get(number).second(); return numbers.stream().map(number -> {
results.add(uuid != null); var uuid = registered.get(number).second();
} return uuid != null;
return results; }).collect(Collectors.toList());
} }
@Override @Override