corda / net.corda.client.fxutils / ChosenList

# ChosenList

`class ChosenList<E> : ObservableListBase<E>`

ChosenList manages an ObservableList that may be changed by the wrapping ObservableValue. Whenever the underlying ObservableValue changes the exposed list changes to the new value. Changes to the list are simply propagated.

Example: val filteredStates = ChosenList(EasyBind.map(filterCriteriaType) { type -> when (type) { is (ByCurrency) -> statesFilteredByCurrency is (ByIssuer) -> statesFilteredByIssuer } })

The above will create a list that chooses and delegates to the appropriate filtered list based on the type of filter.

### Constructors

<init> | `ChosenList(chosenListObservable: ObservableValue<out ObservableList<out E>>)` ChosenList manages an ObservableList that may be changed by the wrapping ObservableValue. Whenever the underlying ObservableValue changes the exposed list changes to the new value. Changes to the list are simply propagated.

### Properties

size | `val size: Int`

### Functions

get | `fun get(index: Int): E`

### Extension Functions

associateBy | `fun <K, A, B> ObservableList<out A>.associateBy(toKey: (A) -> K, assemble: (K, A) -> B): ObservableMap<K, B>` data class Person(val height: Long) val people: ObservableList = (..) val nameToHeight: ObservableMap<String, Long> = people.associateBy(Person::name) { name, person -> person.height } `fun <K, A> ObservableList<out A>.associateBy(toKey: (A) -> K): ObservableMap<K, A>` val people: ObservableList = (..) val nameToPerson: ObservableMap<String, Person> = people.associateBy(Person::name)
associateByAggregation | `fun <K : Any, A : Any, B> ObservableList<out A>.associateByAggregation(toKey: (A) -> K, assemble: (K, A) -> B): ObservableMap<K, ObservableList<B>>` val people: ObservableList = (..) val heightToNames: ObservableMap<Long, ObservableList> = people.associateByAggregation(Person::height) { name, person -> person.name } `fun <K : Any, A : Any> ObservableList<out A>.associateByAggregation(toKey: (A) -> K): ObservableMap<K, ObservableList<A>>` val people: ObservableList = (..) val heightToPeople: ObservableMap<Long, ObservableList> = people.associateByAggregation(Person::height)
filter | `fun <A> ObservableList<out A>.filter(predicate: ObservableValue<(A) -> Boolean>): ObservableList<A>` enum class FilterCriterion { HEIGHT, NAME } val filterCriterion: ObservableValue = (..) val people: ObservableList = (..) fun filterFunction(filterCriterion: FilterCriterion): (Person) -> Boolean { .. }
filterNotNull | `fun <A> ObservableList<out A?>.filterNotNull(): ObservableList<A>` data class Dog(val owner: Person?) val dogs: ObservableList = (..) val owners: ObservableList = dogs.map(Dog::owner).filterNotNull()
first | `fun <A> ObservableList<A>.first(): ObservableValue<A?>`
firstOrDefault | `fun <A> ObservableList<A>.firstOrDefault(default: ObservableValue<A?>, predicate: (A) -> Boolean): ObservableValue<A?>` Return first element of the observable list as observable value. Return provided default value if the list is empty.
firstOrNullObservable | `fun <A> ObservableList<A>.firstOrNullObservable(predicate: (A) -> Boolean): ObservableValue<A?>` Return first element of the observable list as observable value. Return ObservableValue(null) if the list is empty.
foldObservable | `fun <A, B> ObservableList<out A>.foldObservable(initial: B, folderFunction: (B, A) -> B): ObservableValue<B>` val people: ObservableList = (..) val concatenatedNames = people.foldObservable("", { names, person -> names + person.name }) val concatenatedNames2 = people.map(Person::name).fold("", String::plus)
getValueAt | `fun <A> ObservableList<A>.getValueAt(index: Int): ObservableValue<A?>`
indexOfOrThrow | `fun <T> List<T>.indexOfOrThrow(item: T): Int` Returns the index of the given item or throws IllegalArgumentException if not found.
last | `fun <A> ObservableList<A>.last(): ObservableValue<A?>`
leftOuterJoin | `fun <A : Any, B : Any, C, K : Any> ObservableList<A>.leftOuterJoin(rightTable: ObservableList<B>, leftToJoinKey: (A) -> K, rightToJoinKey: (B) -> K, assemble: (A, ObservableList<B>) -> C): ObservableList<C>` data class Person(val name: String, val managerName: String) val people: ObservableList = (..) val managerEmployeeMapping: ObservableList<Pair<Person, ObservableList>> = people.leftOuterJoin(people, Person::name, Person::managerName) { manager, employees -> Pair(manager, employees) } `fun <A : Any, B : Any, K : Any> ObservableList<A>.leftOuterJoin(rightTable: ObservableList<B>, leftToJoinKey: (A) -> K, rightToJoinKey: (B) -> K): ObservableMap<K, Pair<ObservableList<A>, ObservableList<B>>>` data class Person(name: String, favouriteSpecies: Species) data class Animal(name: String, species: Species) val people: ObservableList = (..) val animals: ObservableList = (..) val peopleToFavouriteAnimals: ObservableMap<Species, Pair<ObservableList, ObservableList>> = people.leftOuterJoin(animals, Person::favouriteSpecies, Animal::species)
map | `fun <A, B> ObservableList<out A>.map(cached: Boolean = true, function: (A) -> B): ObservableList<B>` val dogs: ObservableList = (..) val dogOwners: ObservableList = dogs.map { it.owner }
noneOrSingle | `fun <T> Iterable<T>.noneOrSingle(predicate: (T) -> Boolean): T?` Returns the single element matching the given predicate, or `null` if element was not found, or throws if more than one element was found. `fun <T> Iterable<T>.noneOrSingle(): T?` Returns single element, or `null` if element was not found, or throws if more than one element was found.
randomOrNull | `fun <T> List<T>.randomOrNull(): T?` Returns a random element in the list, or null if empty `fun <T> List<T>.randomOrNull(predicate: (T) -> Boolean): T?` Returns a random element in the list matching the given predicate, or null if none found
unique | `fun <T : Any> ObservableList<T>.unique(): ObservableList<T>`