Directory

← Back

LambdaConverter

Allows the use of lambda expressions as converters - Java 8 only

Author

Rating

Requires Java 8!

This add-on provides a single generic class containing the boiler-plate code for converters, thus you only need to provide the concrete types and actual conversion code as lambdas.

See the example below.

Note: this addon is meaningless with Vaadin 8, I'm just leaving it here for backward compatibility.

Sample code

TextField somePriceField = new TextField();

// We want to get the price as a Double, not String.
somePriceField.setConverter(new LambdaConverter<String, Double>(String.class, Double.class,
			stringValue -> Double.parseDouble(stringValue.endsWith("€") ? stringValue.substring(0, stringValue.length() - 1) : stringValue), 
			doubleValue -> doubleValue + "€"));

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2015-02-17
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.3+
Browser
Browser Independent
Online