Skip to content

Commit

Permalink
Merge pull request quarkusio#12132 from gsmet/hv-annotations-dotnames
Browse files Browse the repository at this point in the history
Use DotNames for BeanValidationAnnotationsBuildItem
  • Loading branch information
machi1990 committed Sep 16, 2020
2 parents 1af0f6d + 91c11d6 commit ebfeffc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
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);
}

}

0 comments on commit ebfeffc

Please sign in to comment.