Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DotNames for BeanValidationAnnotationsBuildItem #12132

Merged
merged 2 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.validation.ClockProvider;
import javax.validation.Constraint;
Expand Down Expand Up @@ -203,9 +202,9 @@ public void build(HibernateValidatorRecorder recorder, RecorderContext recorderC
allConsideredAnnotations.add(VALIDATE_ON_EXECUTION);

beanValidationAnnotations.produce(new BeanValidationAnnotationsBuildItem(
VALID.toString(),
constraints.stream().map(a -> a.toString()).collect(Collectors.toSet()),
allConsideredAnnotations.stream().map(a -> a.toString()).collect(Collectors.toSet())));
VALID,
constraints,
allConsideredAnnotations));

Set<DotName> classNamesToBeValidated = new HashSet<>();
Map<DotName, Set<SimpleMethodSignatureKey>> inheritedAnnotationsToBeValidated = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Collections;
import java.util.Set;

import org.jboss.jandex.DotName;

import io.quarkus.builder.item.SimpleBuildItem;

/**
Expand All @@ -11,25 +13,25 @@
*/
public final class BeanValidationAnnotationsBuildItem extends SimpleBuildItem {

private final String valid;
private final Set<String> constraints;
private final Set<String> all;
private final DotName valid;
private final Set<DotName> constraints;
private final Set<DotName> all;

public BeanValidationAnnotationsBuildItem(String valid, Set<String> constraints, Set<String> all) {
public BeanValidationAnnotationsBuildItem(DotName valid, Set<DotName> constraints, Set<DotName> all) {
this.valid = valid;
this.constraints = Collections.unmodifiableSet(constraints);
this.all = Collections.unmodifiableSet(all);
}

public String getValidAnnotation() {
public DotName getValidAnnotation() {
return valid;
}

public Set<String> getConstraintAnnotations() {
public Set<DotName> getConstraintAnnotations() {
return constraints;
}

public Set<String> getAllAnnotations() {
public Set<DotName> getAllAnnotations() {
return all;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ final class DotNames {
static final DotName UNI = DotName.createSimple(Uni.class.getName());
static final DotName MULTI = DotName.createSimple(Multi.class.getName());
static final DotName BUFFER = DotName.createSimple(Buffer.class.getName());
static final DotName RX_BUFFER = DotName.createSimple(io.vertx.reactivex.core.buffer.Buffer.class.getName());
static final DotName MUTINY_BUFFER = DotName.createSimple(io.vertx.mutiny.core.buffer.Buffer.class.getName());
static final DotName RX_HTTP_SERVER_RESPONSE = DotName
.createSimple(io.vertx.reactivex.core.http.HttpServerResponse.class.getName());
static final DotName RX_HTTP_SERVER_REQUEST = DotName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.vertx.web.deployment;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.Type;

Expand Down Expand Up @@ -45,8 +44,7 @@ boolean requireValidation() {
return false;
}
for (AnnotationInstance annotation : method.annotations()) {
String name = annotation.name().toString();
if (validationAnnotations.getAllAnnotations().contains(name)) {
if (validationAnnotations.getAllAnnotations().contains(annotation.name())) {
return true;
}
}
Expand All @@ -61,8 +59,7 @@ boolean isProducedResponseValidated() {
return false;
}
for (AnnotationInstance annotation : method.annotations()) {
String name = annotation.name().toString();
if (validationAnnotations.getValidAnnotation().equals(name)) {
if (validationAnnotations.getValidAnnotation().equals(annotation.name())) {
return true;
}
}
Expand Down Expand Up @@ -103,16 +100,15 @@ boolean isContentTypeRxBuffer() {
if (type == null) {
return false;
}
return type.name()
.equals(DotName.createSimple(io.vertx.reactivex.core.buffer.Buffer.class.getName()));
return type.name().equals(DotNames.RX_BUFFER);
}

boolean isContentTypeMutinyBuffer() {
Type type = getContentType();
if (type == null) {
return false;
}
return type.name().equals(DotName.createSimple(io.vertx.mutiny.core.buffer.Buffer.class.getName()));
return type.name().equals(DotNames.MUTINY_BUFFER);
}

}