com.r3corda.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

filter fun <A> ObservableList<out A>.filter(predicate: ObservableValue<(A) -> Boolean>): ObservableList<out A>

enum class FilterCriterion { HEIGHT, NAME } val filterCriterion: ObservableValue = (..) val people: ObservableList = (..) fun filterFunction(filterCriterion: FilterCriterion): (Person) -> Boolean { .. }

fold fun <A, B> ObservableList<out A>.fold(initial: B, folderFunction: (B, A) -> B): ObservableValue<B>

val people: ObservableList = (..) val concatenatedNames = people.fold("", { names, person -> names + person.name }) val concatenatedNames2 = people.map(Person::name).fold("", String::plus)

indexOfOrThrow fun <T> List<T>.indexOfOrThrow(item: T): Int

Returns the index of the given item or throws IllegalArgumentException if not found.

map fun <A, B> ObservableList<out A>.map(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.