public final class ComponentGeneratorUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static org.jboss.forge.roaster.model.source.ParameterSource<org.jboss.forge.roaster.model.source.JavaClassSource> |
addMethodParameter(org.jboss.forge.roaster.model.source.JavaClassSource javaClass,
org.jboss.forge.roaster.model.source.MethodSource<org.jboss.forge.roaster.model.source.JavaClassSource> method,
Class<?> type,
String name)
Adds a parameter with the specified
type and name to the
given method, considering simple name for java.lang
package. |
static String |
convertCamelCaseToHyphens(String text)
Converts a string in camel-case to a lower case string where each term is
separated by an hyphen.
|
static String |
convertFilePathToPackage(String path)
Generates a package name based on a file path structure.
|
static File |
convertPackageToDirectory(File basePath,
String packageName,
boolean createDirectories)
Generates the directory structure based on a package name.
|
static String |
formatStringToJavaComment(String input)
Formats and ordinary String as a multi-line Java comment, that can be
safely added to any part of a Java code.
|
static String |
formatStringToValidJavaIdentifier(String name)
Same as calling
formatStringToValidJavaIdentifier(String, boolean) with
false - not ignoring Java reserved words. |
static String |
formatStringToValidJavaIdentifier(String name,
boolean ignoreReservedWords)
Formats a given name (which can be a property name, function name or
event name) to a valid Java identifier.
|
static String |
generateElementApiGetterForType(ComponentBasicType basicType,
String propertyName)
Generates a code snippet that uses the
Element API to retrieve
properties from the client model. |
static String |
generateElementApiSetterForType(ComponentBasicType basicType,
String propertyName,
String parameterName,
boolean nullable)
Generates a code snippet that uses the
Element API to set
properties to the client model. |
static String |
generateElementApiValueGetterForType(ComponentBasicType basicType,
String propertyName)
Generates a code snippet that uses the
Element API to retrieve
properties from the client model when it implements the HasValue
contract. |
static String |
generateMethodNameForProperty(String prefix,
String propertyName)
Formats property name to valid java identifier with CamelCase
|
static String |
generateValidJavaClassName(String webcomponentClassName)
Creates a valid Java class name based on the ES6 class name.
|
static Class<?> |
toJavaType(ComponentBasicType type)
Converts a javascript basic type to a Java type.
|
public static String generateValidJavaClassName(String webcomponentClassName)
webcomponentClassName - The ES6 class name.public static String generateMethodNameForProperty(String prefix, String propertyName)
prefix - property prefix (e.g. set, get, is etc.), not
nullpropertyName - property name to convertpublic static String formatStringToValidJavaIdentifier(String name)
formatStringToValidJavaIdentifier(String, boolean) with
false - not ignoring Java reserved words.name - The name of the property that would be exposed to Java code.public static String formatStringToValidJavaIdentifier(String name, boolean ignoreReservedWords)
If the end result is a Java reserved word, and the flag
ignoreReservedWords is false, the identifier is
suffixed with the _ character.
name - The name of the property that would be exposed to Java code.ignoreReservedWords - true to ignore Java reserved words, such as "if"
and "for", false otherwise.Character.isJavaIdentifierStart(char),
Character.isJavaIdentifierPart(char)public static File convertPackageToDirectory(File basePath, String packageName, boolean createDirectories) throws IOException
basePath - The base path of the directory to be generated.packageName - The name of the package to be converted to directories.createDirectories - true to actually create the directories on the
disk, false to just generate the File objects
without creating them.IOException - When createDirectories is true and the target
directory cannot be created.public static String convertFilePathToPackage(String path)
path - The file path to be converted to a package name, such as
"/components/vaadin-button/vaadin-button.html".public static String formatStringToJavaComment(String input)
input - The text to be converted as a comment. Should not be
null.public static String generateElementApiGetterForType(ComponentBasicType basicType, String propertyName)
Element API to retrieve
properties from the client model.basicType - The javascript basic type of the property.propertyName - The name of the property in the javascript model.public static String generateElementApiValueGetterForType(ComponentBasicType basicType, String propertyName)
Element API to retrieve
properties from the client model when it implements the HasValue
contract.
The getter checks whether the return value is null, and
returns HasValue.getEmptyValue().
basicType - The javascript basic type of the property.propertyName - The name of the property in the javascript model.public static String generateElementApiSetterForType(ComponentBasicType basicType, String propertyName, String parameterName, boolean nullable)
Element API to set
properties to the client model.basicType - The javascript basic type of the property.propertyName - The name of the property in the javascript model.parameterName - The name of the parameter in the Java source code.nullable - whether the value can be null or notpublic static Class<?> toJavaType(ComponentBasicType type)
type - The javascript basic type.public static String convertCamelCaseToHyphens(String text)
For instance: hasValue would be converted to has-value.
text - the text to be convertedpublic static org.jboss.forge.roaster.model.source.ParameterSource<org.jboss.forge.roaster.model.source.JavaClassSource> addMethodParameter(org.jboss.forge.roaster.model.source.JavaClassSource javaClass,
org.jboss.forge.roaster.model.source.MethodSource<org.jboss.forge.roaster.model.source.JavaClassSource> method,
Class<?> type,
String name)
type and name to the
given method, considering simple name for java.lang
package.javaClass - the java classmethod - the method to add the parameter totype - the parameter typename - the parameter nameCopyright © 2000–2019 Vaadin Ltd. All rights reserved.