Skip to content

Commit

Permalink
Merge branch 'main' into refactor/generator-cli/file-read
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	packages/ts/generator-cli/package.json
  • Loading branch information
Lodin committed Feb 20, 2025
2 parents e12c12c + 0f5464d commit bfac16d
Show file tree
Hide file tree
Showing 94 changed files with 4,246 additions and 4,038 deletions.
126 changes: 63 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ public String checkValueForAnnotatedElement(Object value,
}
if (annotatedElement instanceof Method) {
return checkValueForType(value,
((Method) annotatedElement).getGenericReturnType(),
requiredByContext);
((Method) annotatedElement).getGenericReturnType());
}
return null;
}

String checkValueForType(Object value, Type expectedType,
boolean requiredByContext) {
return new ExplicitNullableTypeCheckerHelper(requiredByContext)
.checkValueForType(value, expectedType);
String checkValueForType(Object value, Type expectedType) {
return new ExplicitNullableTypeCheckerHelper().checkValueForType(value,
expectedType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.vaadin.hilla.parser.utils.Generics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNullApi;

import static com.vaadin.hilla.ExplicitNullableTypeChecker.isRequired;

Expand All @@ -49,22 +50,10 @@ class ExplicitNullableTypeCheckerHelper {
// A map for tracking already visited Beans.
private Map<Type, Set<Object>> visitedBeans;

private boolean requiredByContext;

private static Logger getLogger() {
return LoggerFactory.getLogger(EndpointController.class);
}

/**
* Creates a new helper.
*
* @param requiredByContext
* {@code true} if the context defines that the node is required
*/
public ExplicitNullableTypeCheckerHelper(boolean requiredByContext) {
this.requiredByContext = requiredByContext;
}

/**
* Check if the Bean value and type have been visited.
*/
Expand Down Expand Up @@ -208,10 +197,14 @@ private String checkBeanFields(Object value, Type expectedType) {
}
markAsVisited(value, expectedType);
Class<?> clazz = (Class<?>) expectedType;
// the context is the package where the object is defined
boolean requiredByContext = clazz.getPackage() != null
&& clazz.getPackage().isAnnotationPresent(NonNullApi.class);
try {
for (PropertyDescriptor propertyDescriptor : Introspector
.getBeanInfo(clazz).getPropertyDescriptors()) {
if (!isPropertySubjectForChecking(propertyDescriptor)) {
if (!isPropertySubjectForChecking(propertyDescriptor,
requiredByContext)) {
continue;
}

Expand Down Expand Up @@ -239,7 +232,7 @@ private String checkBeanFields(Object value, Type expectedType) {
}

private boolean isPropertySubjectForChecking(
PropertyDescriptor propertyDescriptor) {
PropertyDescriptor propertyDescriptor, boolean requiredByContext) {
try {
String name = propertyDescriptor.getName();
Method readMethod = propertyDescriptor.getReadMethod();
Expand Down
Loading

0 comments on commit bfac16d

Please sign in to comment.