User Tools

Site Tools


Sidebar

Dave Orme muses about data-first development.

My current work emphasizes data engineering and analysis using Kubernetes, Clojure, Scala, Eclipse, and Google Cloud Platform or AWS.


Blog

The Cloud

Scala, Clojure, and FP

Data-First Development

Agile

Older work

Coconut Palm Software home


Donate Bitcoin:

1Ecnr9vtkC8b9FvmQjQaJ9ZsHB127UzVD6

Keywords:

Kubernetes, Docker, Streaming Data, Spark, Scala, Clojure, OSGi, Karaf, GCP, AWS, SQL

Disclaimer:

Everything I say here is my own opinion and not necessarily that of my employer.

java:builder_pattern_for_data_binding_nested_attributes

Boris convinced me to keep the order of method calls similar to what you'd expect in regular nested method calls. e.g. if I want to observe person.getAddress().getStreet() the code should look like:

IValueProperty personAddressStreet = BeanPropertyBuilder.value(Person.class, “address”).value(Address.class, “street”).build();

or:

IValueProperty personAddressStreet = BeanPropertyBuilder.value(Person.class, “address”).value(“street”).build();

or even:

IValueProperty objectAddressStreet = BeanPropertyBuilder.value(“address”).value(“street”).build();

This latter example presumes support for generic bean properties (bug 247997). In this case the builder will try to infer the bean class from the value type / element type of the previous property. If the bean class can be inferred it is used; otherwise a generic bean property will be used.

This leads to interesting possibilities:

IListProperty friendsFathersFirstNames = BeanPropertyBuilder.list(Person.class, “friends”).value(“father”).value(“firstName”).build(); IObservableList friendsFathersFirstNamesObservable = PropertyObservables.observeList(person, friendsFathersFirstNames);

java/builder_pattern_for_data_binding_nested_attributes.txt · Last modified: 2014/10/17 22:08 (external edit)