Class BadgePolicy
The counterpart of StylePolicy for the three badge commands, and
extracted for the same reason: these decisions are about Vaadin, not about
Java. Each badge has two vocabularies — in a Lumo project it writes Lumo
utility class names, otherwise CSS values — and which one applies is chosen
at runtime by AppThemeUtils.isLumo(). Written once per language that
would be two sets of answers, and the second would be the one nobody updates.
Deliberately holds no JavaParser and no PSI. Turning an answer into source
text stays with each rewriter: for Lumo that is building the
addClassNames(LumoUtility.…) argument, which is where the policy and
the syntax genuinely meet.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe CSS properties the alignment badge owns, named as the frontend sends them.The two alignment properties with no Lumo utility class. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgapValueOf(String token) The CSS value a gap token stands for, as ingap-m→var(--vaadin-gap-m).static booleanisGapProperty(String property) Whether an inline style belongs to the gap badge, and so should be cleared before it writes.static booleanisPaddingProperty(String property) Whether an inline style belongs to the padding badge.lumoFieldFor(String innerClassName, String cssClassName) The field that holds a CSS class name, within one inner class.lumoFieldsOf(String innerClassName) The constants of oneLumoUtilityinner class, by field name.static StringlumoVariableFor(String cssClassName) The constant naming a CSS class, searched across everyLumoUtilityinner class.static StringpaddingValueOf(String token) The CSS value a padding token stands for, as inpt-l→var(--vaadin-padding-l).
-
Field Details
-
ALIGNMENT_PROPERTIES
The CSS properties the alignment badge owns, named as the frontend sends them.Used to clear what a previous alignment left behind before writing the new one — so the badge cannot accumulate contradictory declarations.
-
ALIGNMENT_PROPERTIES_WITHOUT_LUMO_CLASSES
The two alignment properties with no Lumo utility class.They are written as inline styles whichever theme is in use, which is the single place the two branches agree.
-
-
Method Details
-
gapValueOf
The CSS value a gap token stands for, as ingap-m→var(--vaadin-gap-m).- Parameters:
token- the token the badge sends, ornull- Returns:
- the CSS value, or
nullwhen there is no token or the size is not one this knows
-
paddingValueOf
The CSS value a padding token stands for, as inpt-l→var(--vaadin-padding-l).- Parameters:
token- the token the badge sends, ornull- Returns:
- the CSS value, or
nullwhen there is no token or the size is not one this knows
-
isGapProperty
Whether an inline style belongs to the gap badge, and so should be cleared before it writes.- Parameters:
property- the CSS property- Returns:
- true if the gap badge owns it
-
isPaddingProperty
Whether an inline style belongs to the padding badge.- Parameters:
property- the CSS property- Returns:
- true if the padding badge owns it
-
lumoFieldsOf
The constants of oneLumoUtilityinner class, by field name.Reflection rather than a hard-coded table, so the set cannot drift from the Vaadin version the application is built against.
- Parameters:
innerClassName- the inner class, as inGaporPadding.Top- Returns:
- field name to CSS class name, in no particular order
-
lumoFieldFor
The field that holds a CSS class name, within one inner class.- Parameters:
innerClassName- the inner class to look incssClassName- the class name the badge sent, as ingap-m- Returns:
- the field name, as in
MEDIUM, or empty when that inner class has no such constant
-
lumoVariableFor
The constant naming a CSS class, searched across everyLumoUtilityinner class.Returns the reference as source text —
LumoUtility.Gap.MEDIUM— which is spelled the same in Java and in Kotlin, so it stays policy rather than syntax.- Parameters:
cssClassName- the class name to look for- Returns:
- the reference, or
nullwhen no constant holds that value
-