Class AbstractSuperFloatingPointField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T>,T>
-
- com.vaadin.flow.component.customfield.CustomField<T>
-
- org.vaadin.miki.superfields.numbers.AbstractSuperNumberField<T,SELF>
-
- org.vaadin.miki.superfields.numbers.AbstractSuperFloatingPointField<T,SELF>
-
- Type Parameters:
T- Type of number.SELF- Self type.
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,com.vaadin.flow.component.shared.HasClearButton,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.textfield.HasPrefixAndSuffix,com.vaadin.flow.data.value.HasValueChangeMode,Serializable,TextSelectionNotifier<SELF>,CanReceiveSelectionEventsFromClient,CanSelectText,HasHelperPositionable,HasId,HasLabelPositionable,HasLocale,HasNullValueOptionallyAllowed<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,HasPlaceholder,HasRequired,WithClearButtonMixin<SELF>,WithHelperMixin<SELF>,WithHelperPositionableMixin<SELF>,WithIdMixin<SELF>,WithLabelMixin<SELF>,WithLabelPositionableMixin<SELF>,WithLocaleMixin<SELF>,WithNullValueOptionallyAllowedMixin<SELF,com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,WithPlaceholderMixin<SELF>,WithReceivingSelectionEventsFromClientMixin<SELF>,WithRequiredMixin<SELF>,WithTooltipMixin<SELF>,WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,SELF>
- Direct Known Subclasses:
SuperBigDecimalField,SuperDoubleField
public abstract class AbstractSuperFloatingPointField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>> extends AbstractSuperNumberField<T,SELF>
Base class for implementations ofAbstractSuperNumberFieldthat allow modifications to minimum and maximum number of fraction digits. Those methods by default are hidden from public access.- Since:
- 2020-04-08
- Author:
- miki
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
-
-
Field Summary
-
Fields inherited from interface org.vaadin.miki.markers.HasHelperPositionable
HELPER_ABOVE_THEME_VARIANT
-
Fields inherited from interface org.vaadin.miki.markers.HasLabelPositionable
LABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSuperFloatingPointField(T defaultValue, com.vaadin.flow.function.SerializablePredicate<T> negativityPredicate, com.vaadin.flow.function.SerializableFunction<T,T> turnToPositiveOperator, String label, Locale locale, int maxFractionDigits)Creates the field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisIntegerPartOptional()Checks whether the integer part of a floating-point number is optional.voidsetIntegerPartOptional(boolean required)Sets whether the integer part of a floating-point number is optional.voidsetMaximumFractionDigits(int digits)Sets the maximum number of fraction digits displayed and allowed.voidsetMinimumFractionDigits(int digits)Sets the minimum number of fraction digits displayed.SELFwithIntegerPartOptional()ChainssetIntegerPartOptional(boolean)withtrueas parameter and returns itself.SELFwithIntegerPartOptional(boolean optional)ChainssetIntegerPartOptional(boolean)and returns itself.SELFwithIntegerPartRequired()ChainssetIntegerPartOptional(boolean)withfalseas parameter and returns itself.SELFwithMaximumFractionDigits(int digits)ChainssetMaximumFractionDigits(int)and returns itself.SELFwithMinimumFractionDigits(int digits)ChainssetMinimumFractionDigits(int)and returns itself.-
Methods inherited from class org.vaadin.miki.superfields.numbers.AbstractSuperNumberField
addTextSelectionListener, addThemeVariants, blur, buildRegularExpression, escapeDot, focus, generateModelValue, getErrorMessage, getHelperComponent, getHelperText, getLabel, getLabelPosition, getLocale, getPlaceholder, getPrefixComponent, getRawValue, getRegexp, getSuffixComponent, getTooltip, getValueChangeMode, getValueChangeTimeout, isAutoselect, isClearButtonVisible, isFocused, isGroupingSeparatorHiddenOnFocus, isHelperAbove, isInvalid, isNegativeValueAllowed, isNullValueAllowed, isReadOnly, isReceivingSelectionEventsFromClient, isRequired, isRequiredIndicatorVisible, parseRawValue, removeThemeVariants, select, selectAll, selectNone, setAutoselect, setClearButtonVisible, setDecimalFormat, setErrorMessage, setGroupingSeparatorHiddenOnFocus, setHelperAbove, setHelperAbove, setHelperBelow, setHelperComponent, setHelperText, setId, setInvalid, setLabel, setLabelPosition, setLocale, setMaximumIntegerDigits, setNegativeValueAllowed, setNullValueAllowed, setPlaceholder, setPrefixComponent, setPresentationValue, setReadOnly, setReceivingSelectionEventsFromClient, setRequired, setRequiredIndicatorVisible, setSuffixComponent, setTooltipText, setValueChangeMode, setValueChangeTimeout, updateFieldValue, updateRegularExpression, updateRegularExpression, withAutoselect, withGroupingSeparatorHiddenOnFocus, withMaximumIntegerDigits, withNegativeValueAllowed, withReceivingSelectionEventsFromClient
-
Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, onAttach, remove, removeThemeVariants, updateValue
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue
-
Methods inherited from interface org.vaadin.miki.markers.WithClearButtonMixin
withClearButtonVisible
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperMixin
withHelperComponent, withHelperText
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperPositionableMixin
withHelperAbove, withHelperAbove, withHelperBelow
-
Methods inherited from interface org.vaadin.miki.markers.WithIdMixin
withId
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelMixin
withLabel
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelPositionableMixin
withLabelPosition
-
Methods inherited from interface org.vaadin.miki.markers.WithLocaleMixin
withLocale
-
Methods inherited from interface org.vaadin.miki.markers.WithNullValueOptionallyAllowedMixin
withNullValueAllowed
-
Methods inherited from interface org.vaadin.miki.markers.WithPlaceholderMixin
withPlaceholder
-
Methods inherited from interface org.vaadin.miki.markers.WithRequiredMixin
withoutRequired, withRequired, withRequired
-
Methods inherited from interface org.vaadin.miki.markers.WithTooltipMixin
withTooltipText
-
Methods inherited from interface org.vaadin.miki.markers.WithValueMixin
withValue
-
-
-
-
Constructor Detail
-
AbstractSuperFloatingPointField
protected AbstractSuperFloatingPointField(T defaultValue, com.vaadin.flow.function.SerializablePredicate<T> negativityPredicate, com.vaadin.flow.function.SerializableFunction<T,T> turnToPositiveOperator, String label, Locale locale, int maxFractionDigits)
Creates the field.- Parameters:
defaultValue- Default value to use on startup and when there are errors.negativityPredicate- Check for whether or not given value is negative.turnToPositiveOperator- Operation to turn number into a positive one.label- Label of the field.locale- Locale to use.maxFractionDigits- Max number of fraction digits. Overwrites the settings in format obtained based onlocale.
-
-
Method Detail
-
setMinimumFractionDigits
public void setMinimumFractionDigits(int digits)
Description copied from class:AbstractSuperNumberFieldSets the minimum number of fraction digits displayed. Overwrites the value in the underlyingDecimalFormat. Will be overwritten by calls toAbstractSuperNumberField.setDecimalFormat(DecimalFormat). Calls toAbstractSuperNumberField.setLocale(Locale)will preserve this value. Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).- Overrides:
setMinimumFractionDigitsin classAbstractSuperNumberField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>>- Parameters:
digits- Number of digits to use.
-
setMaximumFractionDigits
public void setMaximumFractionDigits(int digits)
Description copied from class:AbstractSuperNumberFieldSets the maximum number of fraction digits displayed and allowed. Overwrites the value in the underlyingDecimalFormat. Will be overwritten by calls toAbstractSuperNumberField.setDecimalFormat(DecimalFormat). Calls toAbstractSuperNumberField.setLocale(Locale)will preserve this value. Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).- Overrides:
setMaximumFractionDigitsin classAbstractSuperNumberField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>>- Parameters:
digits- Number of digits to use.
-
withMinimumFractionDigits
public final SELF withMinimumFractionDigits(int digits)
ChainssetMinimumFractionDigits(int)and returns itself.- Parameters:
digits- Minimum number of digits to set.- Returns:
- This.
-
withMaximumFractionDigits
public final SELF withMaximumFractionDigits(int digits)
ChainssetMaximumFractionDigits(int)and returns itself.- Parameters:
digits- Maximum number of digits to set.- Returns:
- This.
-
setIntegerPartOptional
public void setIntegerPartOptional(boolean required)
Description copied from class:AbstractSuperNumberFieldSets whether the integer part of a floating-point number is optional. If it is set as optional, numbers can be entered without the integer part, which will be defaulted to zero.- Overrides:
setIntegerPartOptionalin classAbstractSuperNumberField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>>- Parameters:
required- Whether the integer part is optional.
-
isIntegerPartOptional
public boolean isIntegerPartOptional()
Description copied from class:AbstractSuperNumberFieldChecks whether the integer part of a floating-point number is optional.- Overrides:
isIntegerPartOptionalin classAbstractSuperNumberField<T extends Number,SELF extends AbstractSuperFloatingPointField<T,SELF>>- Returns:
- Whether the integer part is optional (
falseby default - integer part is required).
-
withIntegerPartOptional
public final SELF withIntegerPartOptional(boolean optional)
ChainssetIntegerPartOptional(boolean)and returns itself.- Parameters:
optional- Whether the required part is optional or not (default).- Returns:
- This.
-
withIntegerPartRequired
public final SELF withIntegerPartRequired()
ChainssetIntegerPartOptional(boolean)withfalseas parameter and returns itself.- Returns:
- This.
-
withIntegerPartOptional
public final SELF withIntegerPartOptional()
ChainssetIntegerPartOptional(boolean)withtrueas parameter and returns itself.- Returns:
- This.
-
-