Class BindingUtils

java.lang.Object
dev.zemco.codegame.util.BindingUtils

public final class BindingUtils extends Object
Collection of utility functions for simplifying manipulation of JavaFX bindings.

Currently, these functions only consist of helper mapping functions that allow us to transform observable properties using mappers. This was done because recommended solution that JavaFX provides is walking properties using Bindings.selectString(Object, String...). This, in our opinion, is error-prone to changes, and alternatives tend to be harder to read.

To combat this issue we wrap creation of new bindings with simple to use and read mapping interface.

Author:
Erik Zemčík
  • Method Summary

    Modifier and Type
    Method
    Description
    static <F> javafx.beans.binding.StringBinding
    map(javafx.beans.value.ObservableValue<F> property, Function<F,String> mapper)
    Creates binding that maps property to String using a mapper.
    static <F> javafx.beans.binding.StringBinding
    mapOrDefault(javafx.beans.value.ObservableValue<F> property, Function<F,String> mapper, String defaultValue)
    Creates binding that maps property to String using a mapper, falling back to defaultValue if property value is null.
    static <F> javafx.beans.binding.StringBinding
    mapOrNull(javafx.beans.value.ObservableValue<F> property, Function<F,String> mapper)
    Creates binding that maps property to String using a mapper, falling back to null if property value is null.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait