Skip to content

Java web templates: xylo.collections

Stefan Endrullis edited this page Sep 16, 2018 · 3 revisions

This file contains templates for different collection types, such as List, Set, Map, or Option:

  • .toList, .toSet, .toMap - convert arrays, collections, iterables, and streams to lists, sets, or maps
  • .sort, .sortBy - sort arrays, lists, and streams (by attribute)
  • .minBy, .maxBy - find the minimum/maximum in arrays, collections, iterables, and streams
  • .groupBy - group arrays, collections, iterables, and streams by attribute
  • .exists, .forall - test if one/all element(s) of an array, a collection, an iterable, or a stream hold(s) a given condition
  • .reverse - reverse arrays, lists, and strings
  • .concat - concatenate arrays, collections, and streams
  • .join, .mkString - join the elements (strings) of an array, a collection, an iterable, or a stream into one string by using a given separator
  • .stream - convert iterable to stream
  • .map - map the entries of lists, sets, and maps
  • .mapKeys - map the keys of a map
  • .mapValues - map the values of a map
  • .getOrElseUpdate - return the map value of a given key or compute it and return it
  • .filter - filter the elements of lists, sets, maps, and iterables
  • .reduce - reduce the elements of arrays, collections, and iterables
  • .fold - reduce the elements of arrays, collections, and iterables by using a neutral element (similar to Scala fold)
  • .find - find an element in arrays, collections, iterables, and streams
  • .take - take a certain number of elements from a stream
  • .drop - skip a certain number of elements from a stream
  • .size - get the length or an array
  • .get - get an element of an array by index
  • .first, .head - get first element of a list, or an array
  • .head - get last element of a list, or an array
  • .forEach - iterate over arrays, and optionals
  • .isEmpty - null-safe isEmpty check for collections, maps and strings
  • .isNotEmpty - null-safe isNotEmpty check for collections, maps and strings
  • .isBlank - null-safe isBlank check strings
  • .isNotBlank - null-safe isNotBlank check for strings