Package com.vaadin.copilot.allcomponents
Interface AllComponentsComponentGenerator
- All Known Implementing Classes:
AbbrAllComponentsComponentGenerator,AccordionAllComponentsComponentGenerator,AccordionPanelAllComponentsComponentGenerator,AnchorAllComponentsComponentGenerator,ArticleAllComponentsComponentGenerator,AsideAllComponentsComponentGenerator,AvatarGroupAllComponentsComponentGenerator,BadgeAllComponentsComponentGenerator,CardAllComponentsComponentGenerator,ChartAllComponentsComponentGenerator,CheckboxGroupAllComponentsComponentGenerator,CodeAllComponentsComponentGenerator,ConfirmDialogAllComponentsComponentGenerator,ContextMenuAllComponentsComponentGenerator,DashboardAllComponentsComponentGenerator,DateTimePickerAllComponentsComponentGenerator,DefaultAllComponentsComponentGenerator,DescriptionListAllComponentsComponentGenerator,DetailsAllComponentsComponentGenerator,DialogAllComponentsComponentGenerator,FieldSetAllComponentsComponentGenerator,FormLayoutAllComponentsComponentGenerator,GridAllComponentsComponentGenerator,IconAllComponentsComponentGenerator,IFrameAllComponentsComponentGenerator,ImageAllComponentsComponentGenerator,ListItemAllComponentsComponentGenerator,MapAllComponentsComponentGenerator,MarkdownAllComponentsComponentGenerator,MenuBarAllComponentsComponentGenerator,MessageListAllComponentsComponentGenerator,NativeDetailsAllComponentsComponentGenerator,NavAllComponentsComponentGenerator,NotificationAllComponentsComponentGenerator,OrderedListAllComponentsComponentGenerator,ParamAllComponentsComponentGenerator,PopoverAllComponentsComponentGenerator,PreAllComponentsComponentGenerator,ProgressBarAllComponentsComponentGenerator,RichTextEditorAllComponentsComponentGenerator,SectionAllComponentsComponentGenerator,SideNavAllComponentsComponentGenerator,SplitLayoutAllComponentsComponentGenerator,TabAllComponentsComponentGenerator,TabsAllComponentsComponentGenerator,TabSheetAllComponentsComponentGenerator,UnorderedListAllComponentsComponentGenerator
public interface AllComponentsComponentGenerator
Provides component-specific behavior while generating a All Components view.
Implementations identify the component class they support and can customize
example generation, styling, and generated statements.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidAdds component-specific statements to the generated example.default booleanaddDefaultWithoutVariant(Class<?> componentClazz) Determines whether an example without a theme variant should be added.getVariantExpression(AllComponentsComponentGeneratorContext context, String variableName) Gets the variant name from the addThemeVariants calldefault StringgetVariantNameExpressionOrDefaultStringLiteral(AllComponentsComponentGeneratorContext context, String variableName, String defaultVarName) Generates formatVariantName call for components that have addThemeVariants call.default booleanChecks whether a class has a public method with compatible parameter types.default booleanhasMethodWithParameterTypeNames(Class<?> clazz, String methodName, String... parameterTypeNames) Checks whether a class has a public method with parameters matching the supplied fully qualified type names.default booleanDetermines whether this generator supports a component class.default intmaxShowcaseColumns(Class<?> componentClazz) Gets the maximum number of columns for the component's showcase grid.default booleanparameterNamesMatch(Method method, String... parameterTypeNames) Determines whether a method has parameters with the supplied fully qualified type names.default booleanparametersMatch(Method method, Class<?>... parameterTypes) Determines whether a method accepts the supplied argument types.default booleanpopulateForEachThemeVariant(Class<?> componentClazz) Determines whether examples should be populated for every available theme variant.default booleanshouldGenerateExample(Class<?> componentClazz) Determines whether an example should be generated for a component.Gets inline styles to apply to generated component instances.Gets the fully qualified name of the component class targeted by this generator.
-
Method Details
-
targetFullyQualifiedClassName
String targetFullyQualifiedClassName()Gets the fully qualified name of the component class targeted by this generator.- Returns:
- the target class name, or
nullwhen the generator is the default fallback
-
matches
Determines whether this generator supports a component class.- Parameters:
componentClazz- the component class being generatedinheritanceChain- the component class and its superclasses- Returns:
truewhen the target class matches the component or one of its superclasses
-
shouldGenerateExample
Determines whether an example should be generated for a component.- Parameters:
componentClazz- the component class being generated- Returns:
trueto generate an example
-
populateForEachThemeVariant
Determines whether examples should be populated for every available theme variant.- Parameters:
componentClazz- the component class being generated- Returns:
trueto generate examples for each theme variant
-
addDefaultWithoutVariant
Determines whether an example without a theme variant should be added.- Parameters:
componentClazz- the component class being generated- Returns:
trueto add the default example
-
styles
Gets inline styles to apply to generated component instances.- Parameters:
componentClazz- the component class being generated- Returns:
- CSS property names and values to apply
-
addCustomStatements
Adds component-specific statements to the generated example.- Parameters:
context- context containing the generated block and component details
-
maxShowcaseColumns
Gets the maximum number of columns for the component's showcase grid. Wide components should return1so each example spans the full card width.- Parameters:
componentClazz- the component class being generated- Returns:
- the maximum column count,
3by default
-
hasMethod
Checks whether a class has a public method with compatible parameter types.- Parameters:
clazz- the class to inspectmethodName- the method name to findparameterTypes- argument types that must be accepted by the method- Returns:
trueif a compatible method exists
-
hasMethodWithParameterTypeNames
default boolean hasMethodWithParameterTypeNames(Class<?> clazz, String methodName, String... parameterTypeNames) Checks whether a class has a public method with parameters matching the supplied fully qualified type names.- Parameters:
clazz- the class to inspectmethodName- the method name to findparameterTypeNames- fully qualified parameter type names to match- Returns:
trueif a matching method exists
-
parametersMatch
Determines whether a method accepts the supplied argument types.- Parameters:
method- the method to inspectparameterTypes- argument types that must be accepted by the method- Returns:
trueif the parameter counts match and every argument type is assignable to the corresponding method parameter
-
parameterNamesMatch
Determines whether a method has parameters with the supplied fully qualified type names.- Parameters:
method- the method to inspectparameterTypeNames- fully qualified parameter type names to match- Returns:
trueif the parameter counts and type names match
-
getVariantExpression
default Optional<String> getVariantExpression(AllComponentsComponentGeneratorContext context, String variableName) Gets the variant name from the addThemeVariants call- Parameters:
context- Context of the target componentvariableName- Variable name to find addThemeVariants call- Returns:
- String theme variant e.g. LUMO_PRIMARY
-
getVariantNameExpressionOrDefaultStringLiteral
default String getVariantNameExpressionOrDefaultStringLiteral(AllComponentsComponentGeneratorContext context, String variableName, String defaultVarName) Generates formatVariantName call for components that have addThemeVariants call.- Parameters:
context- Context of the target componentvariableName- Variable name to find addThemeVariantsCalldefaultVarName- Fallback name when there is no theme variants- Returns:
- the variant name as string literal or variant name expr
-