A list of OrgData objects, with methods for filtering, grouping and converting that list. Returned wherever a platform API produces a collection of organisations for use in JS controllers and templates, such as an organisation's child organisations or the results of an organisation search.
Extends: CommonList
Properties
| Property | Returns | Description |
|---|---|---|
| withNoPrimaryMembers | OrgDataList | Filters this list down to organisations that have no primary group memberships. |
| withPrimaryMembers | OrgDataList | Filters this list down to organisations that have at least one primary group membership. |
Inherited from CommonList
Properties
| Property | Returns | Description |
|---|---|---|
| attributes | Map<String,Object> | A general-purpose map for stashing arbitrary values alongside this list, for example to cache data computed while rendering a template. Lazily created on first access, so it is never null. |
| first | T | The first element in this list. |
| last | T | The last element in this list. |
| random | T | Picks a single element from this list at random. |
| randomSort | CommonList<T> | Builds a new list containing this list's elements in a random order. This list is not modified. |
| reverse | CommonList<T> | Builds a new list with the elements of this one in reverse order. This list is not modified. |
Methods
getAttributes() · addQuiet(T t) · getFirst() · getLast() · removeLast() · removeFirst() · getRandom() · getReverse() · getRandomSort() · upTo(int n) · after(int n) · truncate(int maxSize) · forEach(Consumer<? super T> action) · sortByProperty(String propertyName) · sortReverse()
getAttributes()
Returns: Map<String,Object>
A general-purpose map for stashing arbitrary values alongside this list, for example to cache data computed while rendering a template. Lazily created on first access, so it is never null.
addQuiet(T t)
Returns: String
Appends an element to this list, for use directly inside a template expression. Behaves like add(), but returns an empty string instead of a boolean so it does not generate unwanted output when called from a template.
| Parameter | Description |
|---|---|
t | the element to append |
getFirst()
Returns: T
The first element in this list.
getLast()
Returns: T
The last element in this list.
removeLast()
Returns: T
Removes and returns the last element of this list.
removeFirst()
Returns: T
Removes and returns the first element of this list.
getRandom()
Returns: T
Picks a single element from this list at random.
getReverse()
Returns: CommonList<T>
Builds a new list with the elements of this one in reverse order. This list is not modified.
getRandomSort()
Returns: CommonList<T>
Builds a new list containing this list's elements in a random order. This list is not modified.
upTo(int n)
Returns: CommonList<T>
Builds a new list containing at most the first n elements of this list.
| Parameter | Description |
|---|---|
n | the maximum number of leading elements to keep |
after(int n)
Returns: CommonList<T>
Builds a new list with the leading n elements of this list skipped. For example after(2) returns a list without the first 2 elements. The count is 1-indexed, so after(1) skips only the first element and after(0) skips none.
| Parameter | Description |
|---|---|
n | the number of leading elements to skip |
truncate(int maxSize)
Returns: CommonList<T>
Builds a new list containing at most maxSize elements of this list, taken from the start.
| Parameter | Description |
|---|---|
maxSize | the maximum number of elements the new list may contain |
forEach(Consumer<? super T> action)
Returns: void
Applies the given action to each element in this list, in order. Yields to the Governor between elements so that long-running iterations over large lists can be interrupted or throttled.
| Parameter | Description |
|---|---|
action | the action to apply to each element |
sortByProperty(String propertyName)
Returns: CommonList<T>
Builds a new list containing this list's elements sorted by a named bean property, using reflection to read the property from each element. If propertyName is null, or sorting fails for any reason, this same list is returned unchanged.
| Parameter | Description |
|---|---|
propertyName | the name of the bean property to sort elements by |
sortReverse()
Returns: CommonList<T>
Builds a new list with this list's elements in reverse order, by inserting each element at the head of the new list.
Methods
getWithPrimaryMembers()
Returns: OrgDataList
Filters this list down to organisations that have at least one primary group membership.
getWithNoPrimaryMembers()
Returns: OrgDataList
Filters this list down to organisations that have no primary group memberships.
groupByField(String fieldName, String defaultKey)
Returns: Map<String,OrgDataList>
Groups this list by the value of the given org field. Each organisation in this list is placed into the entry whose key is its value for fieldName, falling back to defaultKey when the organisation has no value for that field.
| Parameter | Description |
|---|---|
fieldName | the name of the org field to group by |
defaultKey | the key to use for organisations that have no value for fieldName |
toOrgs()
Returns: List<Organisation>
Converts this list to a plain list of the underlying Organisation entities.
propVal(String s)
Returns: String
Finds the first non-blank value of the given org field across the organisations in this list.
| Parameter | Description |
|---|---|
s | the name of the org field to look up |