private SortedMap<String, NamedTestResult> indexByTestName(List<NamedTestResult> namedTestResults) { Map<String, NamedTestResult> indexedTestResults = index(namedTestResults, on(NamedTestResult.class).getTestName()); SortedMap<String, NamedTestResult> sortedTestResults = Maps.newTreeMap(); sortedTestResults.putAll(indexedTestResults); return sortedTestResults; }
private SortedMap<String, NamedTestResult> indexByTestName(List<NamedTestResult> namedTestResults) { Map<String, NamedTestResult> indexedTestResults = index(namedTestResults, on(NamedTestResult.class).getTestName()); SortedMap<String, NamedTestResult> sortedTestResults = Maps.newTreeMap(); sortedTestResults.putAll(indexedTestResults); return sortedTestResults; }
/** * Indexes the objects in this iterable based on the value of their argument. * @param argument An argument defined using the {@link Lambda#on(Class)} method * @return A map having as keys the argument value extracted from the objects in the given iterable and as values the corresponding objects */ @SuppressWarnings("unchecked") public <K> LambdaMap<K, T> map(K argument) { return new LambdaMap<K, T>((Map<K, T>) Lambda.index(getInner(), argument)); }
/** * Indexes the objects in this iterable based on the value of their argument. * @param argument An argument defined using the {@link Lambda#on(Class)} method * @return A map having as keys the argument value extracted from the objects in the given iterable and as values the corresponding objects */ public <A> LambdaMap<A, T> index(A argument) { return new LambdaMap<A, T>((Map<A, T>)Lambda.index(getInner(), argument)); }
public void validate(FormBeanGroup formGroup, Map<String, FormValidator> validators, List<FormBean> allForms) { try { final List<FormBean> formBeansOrderedByPriority = formGroup.sortByDependency(); final Map<String, FormBean> formBeansIndexedByName = index(formBeansOrderedByPriority, on(FormBean.class).getFormname()); for (FormBean formBean : formBeansOrderedByPriority) { final List<String> invalidDependentForms = getInvalidDependentForms(formBean, formBeansIndexedByName); if (CollectionUtils.isEmpty(invalidDependentForms)) { try { formBean.addFormErrors(validators.get(formBean.getValidator()).validate(formBean, formGroup, allForms)); } catch (Exception e) { formBean.addFormError(new FormError("Form Error:" + formBean.getFormname(), "Server exception, contact your administrator")); log.error("Encountered exception while validating form group, " + formGroup.toString(), e); } } else { formBean.addFormError(new FormError("Form Error:" + join(invalidDependentForms, ","), "Dependent form failed")); } } } catch (Exception e) { formGroup.markAllFormAsFailed("Server exception, contact your administrator"); log.error("Encountered exception while validating form group, " + formGroup.toString(), e); } }