-
- Type Parameters:
M- the model's typeV- the view's type
- All Known Implementing Classes:
AbstractValueTranslator,BMoneyStringTranslator,BooleanBooleanTranslator,ByteStringTranslator,CharArrayCharArrayTranslator,ColorColorTranslator,DateStringTranslator,DoubleStringTranslator,EnumEnumTranslator,EnumStringTranslator,FloatStringTranslator,FractionNumberStringTranslator,IdentityTranslator,IntegerStringTranslator,LocalDateStringConverter,LocalDateTimeStringConverter,LocalTimeStringConverter,LongStringTranslator,NumberStringTranslator,ObservableListTranslator,ShortStringTranslator,StringColorTranslator,StringStringTranslator,ValueStringTranslator
public interface ValueTranslator<M,V>A value translator.
Converts between view and model types.
Notice: tentackle uses the term "translator" instead of "converter" to prevent tentackle-translators from being mixed up with JavaFX StringConverters.
- Author:
- harald
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidbindingPropertiesUpdated()Invoked explicitly by the application after binding properties have been updated.
May be necessary if action must be taken by the translator.
The method is provided for custom translators.FxComponentgetComponent()Gets the component.booleanisLenient()Returns whether parsing to model should be lenient.default booleanneedsToModelTwice()Returns whether toModel must be invoked twice.
An example is a DoubleStringTranslator:
let fraction number input be 1.211111 and formatting scale 2.default MtoModel(V value)Converts a view value to a model value.java.util.function.Function<V,M>toModelFunction()Function to translate a view value to a model value.default VtoView(M value)Converts a model value to a view value.java.util.function.Function<M,V>toViewFunction()Function to translate a model value to a view value.
-
-
-
Method Detail
-
getComponent
FxComponent getComponent()
Gets the component.- Returns:
- the component
-
toViewFunction
java.util.function.Function<M,V> toViewFunction()
Function to translate a model value to a view value.- Returns:
- the function
-
toModelFunction
java.util.function.Function<V,M> toModelFunction()
Function to translate a view value to a model value.- Returns:
- the function
-
isLenient
boolean isLenient()
Returns whether parsing to model should be lenient.- Returns:
- true if lenient, false is default
-
needsToModelTwice
default boolean needsToModelTwice()
Returns whether toModel must be invoked twice.
An example is a DoubleStringTranslator:
let fraction number input be 1.211111 and formatting scale 2.- after first updateModel the model contains 1.211111
- after formatting and updateView, the view contains 1.21 but the model still contains 1.211111
- after second updateModel the model contains the correct value 1.21
- Returns:
- true if needs a second translation roundtrip
-
bindingPropertiesUpdated
default void bindingPropertiesUpdated()
Invoked explicitly by the application after binding properties have been updated.
May be necessary if action must be taken by the translator.
The method is provided for custom translators. Not used by the framework itself.Example:
getBinder().putBindingProperty(DomainContext.class, getDomainContext()); pdoField.getValueTranslator().bindingPropertiesUpdated();
-
toView
default V toView(M value)
Converts a model value to a view value.- Parameters:
value- the model's value- Returns:
- the view's value
-
-