double (String output) { for (Operation operation : Operation.values()) { final Matcher matcher = operation.myPattern.matcher(output); if (matcher.matches()) { try { double operationProgress = operation.getProgress(Integer.parseInt(matcher.group(1))); // progress of this operation myOperationsProgress.put(operation, operationProgress); } catch (NumberFormatException e) { return -1; } return updateTotalProgress(operation); } } return -1; }