Class ComponentSelectHelpers
java.lang.Object
org.vaadin.miki.superfields.componentselect.ComponentSelectHelpers
Contains helpers to be used with
ComponentSelect.- Since:
- 2023-11-17
- Author:
- miki
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends com.vaadin.flow.component.shared.ThemeVariant,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.shared.HasThemeVariant<V>>
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> addVariant(V variant) Returns an action that adds the given variant to the component.static <C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasStyle>
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> changeStyle(String fromStyle, String toStyle) Returns a consumer that changes the style of the component from a given style to another style.static <V extends com.vaadin.flow.component.shared.ThemeVariant,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.shared.HasThemeVariant<V>>
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> removeVariant(V variant) Returns an action that removes the given variant from the component.static <T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasText>
com.vaadin.flow.function.SerializableBiFunction<Integer,T, C> simpleComponentFactory(Supplier<C> constructor) Returns a simple component factory that usesObject.toString()to produce component text.static <T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasText>
com.vaadin.flow.function.SerializableBiFunction<Integer,T, C> simpleComponentFactory(Supplier<C> constructor, Function<T, String> captionGenerator) Returns a simple component factory.
-
Method Details
-
changeStyle
public static <C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasStyle> com.vaadin.flow.function.SerializableBiConsumer<Integer,C> changeStyle(String fromStyle, String toStyle) Returns a consumer that changes the style of the component from a given style to another style.- Type Parameters:
C- Type of the component.- Parameters:
fromStyle- Style to change from (will be removed from the style class names of the component).toStyle- Style to change to (will be added to the style class names of the component).- Returns:
- A
SerializableBiConsumer.
-
addVariant
public static <V extends com.vaadin.flow.component.shared.ThemeVariant,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.shared.HasThemeVariant<V>> com.vaadin.flow.function.SerializableBiConsumer<Integer,C> addVariant(V variant) Returns an action that adds the given variant to the component.- Type Parameters:
V- Theme variant.C- Type of component (must support the given theme variant).- Parameters:
variant- Variant to add.- Returns:
- A
SerializableBiFunction.
-
removeVariant
public static <V extends com.vaadin.flow.component.shared.ThemeVariant,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.shared.HasThemeVariant<V>> com.vaadin.flow.function.SerializableBiConsumer<Integer,C> removeVariant(V variant) Returns an action that removes the given variant from the component.- Type Parameters:
V- Theme variant.C- Type of component (must support the given theme variant).- Parameters:
variant- Variant to remove.- Returns:
- A
SerializableBiFunction.
-
simpleComponentFactory
public static <T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasText> com.vaadin.flow.function.SerializableBiFunction<Integer,T, simpleComponentFactoryC> (Supplier<C> constructor) Returns a simple component factory that usesObject.toString()to produce component text.- Type Parameters:
T- Type of item.C- Type of component.- Parameters:
constructor- Reference to a constructor of a component.- Returns:
- A
SerializableBiFunctionthat returns components with caption.
-
simpleComponentFactory
public static <T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C> & com.vaadin.flow.component.HasText> com.vaadin.flow.function.SerializableBiFunction<Integer,T, simpleComponentFactoryC> (Supplier<C> constructor, Function<T, String> captionGenerator) Returns a simple component factory.- Type Parameters:
T- Type of item.C- Type of component.- Parameters:
constructor- Reference to a constructor of a component.captionGenerator- Function to generate captions.- Returns:
- A
SerializableBiFunctionthat returns components with caption.
-