private Parameter sortParameter(List<Field> restExposedFields, Locale locale) { Parameter sortParameter = queryParameter(SORT_BY_PARAM, msg(locale, SORT_DESC_KEY), STRING_TYPE); List<String> restExposedFieldNames = Lambda.extract(restExposedFields, Lambda.on(Field.class).getName()); sortParameter.setEnumValues(restExposedFieldNames); return sortParameter; }
private List<String> filter(final List<String> words) { final List<Filter> allFilters = new ArrayList<>(); allFilters.add(new StopWordFilter(stopWords)); allFilters.add(new WordSizeFilter(minWordLength, maxWordLength)); allFilters.addAll(filters); final CompositeFilter compositeFilter = new CompositeFilter(allFilters); return Lambda.filter(compositeFilter, words); }
@Test public void shouldNotCreateNewAccountIfUserAlreadyExists() { String userName = "******"; allMotechUsers.add( new MotechUserCouchdbImpl(userName, "testpassword", "", "id", asList("ADMIN"), "")); allMotechUsers.add( new MotechUserCouchdbImpl(userName, "testpassword1", "", "id2", asList("ADMIN"), "")); MotechUser motechUser = allMotechUsers.findByUserName("userName"); final List<MotechUserCouchdbImpl> allWebUsers = ((AllMotechUsersCouchdbImpl) allMotechUsers).getAll(); final int numberOfUsersWithSameUserName = Lambda.select(allWebUsers, HasPropertyWithValue.hasProperty("userName", equalTo(userName))) .size(); assertEquals(1, numberOfUsersWithSameUserName); assertEquals("testpassword", motechUser.getPassword()); assertEquals("id", motechUser.getExternalId()); }
public static <T> T proxy(Class<T> clazz) { return Lambda.on(clazz); }
@SuppressWarnings("unchecked") public static <T> T proxy(T t) { Object object = Lambda.on(t.getClass()); return (T) object; }