Package com.vaadin.hilla
Class ExplicitNullableTypeChecker
java.lang.Object
com.vaadin.hilla.ExplicitNullableTypeChecker
A checker for TypeScript null compatibility in Vaadin endpoint methods
parameter and return types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckValueForAnnotatedElement(Object value, AnnotatedElement annotatedElement, boolean requiredByContext) Validates the given value for the given expected method return value type.static booleanisRequired(boolean requiredByContext, List<com.github.javaparser.ast.expr.AnnotationExpr> annotations) Checks if the parsed node should be required (not nullable) in the generated Typescript code based on the list of annotations.static booleanisRequired(AnnotatedElement element, boolean requiredByContext) Checks if the reflected element should be required (not nullable) in the generated Typescript code based on annotations.
-
Constructor Details
-
ExplicitNullableTypeChecker
public ExplicitNullableTypeChecker()
-
-
Method Details
-
isRequired
Checks if the reflected element should be required (not nullable) in the generated Typescript code based on annotations.- Parameters:
element- an element to be requiredrequiredByContext-trueif the context defines that the node is required- Returns:
- a result of check
-
isRequired
public static boolean isRequired(boolean requiredByContext, List<com.github.javaparser.ast.expr.AnnotationExpr> annotations) Checks if the parsed node should be required (not nullable) in the generated Typescript code based on the list of annotations.- Parameters:
requiredByContext-trueif the context defines that the node is requiredannotations- a list of node annotations to check- Returns:
- a result of check
-
checkValueForAnnotatedElement
public String checkValueForAnnotatedElement(Object value, AnnotatedElement annotatedElement, boolean requiredByContext) Validates the given value for the given expected method return value type.- Parameters:
value- the value to validateannotatedElement- the entity to be type checkedrequiredByContext-trueif the context defines that the node is required- Returns:
- error message when the value is null while the expected type does not explicitly allow null, or null meaning the value is OK.
-